Jump to content
Software FX Community
Sign in to follow this  
MarcoS

[Guest Blogger] Creating a flashing display with out-gauge

Recommended Posts

Last week, I blogged about creating a stock ticker with out-gauge.  This week, I'm going to do a flashing display.

My script will open up a digital type gadget, text will basically flash for about 5 seconds, then remain constantly on the screen.

--------------start flash.ps1--------------- 

#We change the $erroractionpreference here.  If this is the first time this runs, when the new runspace is invoked, an error could occur.
#This may not be the best solution... 

$erroractionpreference="silentlycontinue"

#We create a function to determine if the current tick value is even or odd.  This is how we determine what phase of the flash we are in:
#do we show the string or hide it this run.

function check-even ($num) {[bool]!($num%2)}

#Check if tick had already been defined in the current runspace.

$check=get-variable tick -scope global

#We setup a global variable here.  Global because we are going to use the -refresh parameter
#and need the variable to be available in the new PowerShell runspace created.

if (($check -eq $null)) {$global:tick=0}

#As long as tick is less than 6, in this case, we still want to flash the string.  Once we reach 6,
#the string is shown indefinitely.

if ($global:tick -lt 6) {
  if (check-even $global:tick) {$value="test"} else {$value=""}
} else {
  $value="test"
}

#Increment tick for the next run.

$global:tick++

#Echo the current string to pass off to out-gauge.

$value

--------------stop flash.ps1--------------- 

So once you have the script saved, you can call it like so:

PSH>./flash.ps1|out-gauge -type digital -refresh 0:0:01 -floating -topmost

I still have to blog about the traffic light, and that should be next week.  I am also planning to tie together the stock ticker, flash, and the drilldown feature in a future blog post.

Share this post


Link to post
Share on other sites
Sign in to follow this  

×
×
  • Create New...