I added the timer functionality myself. The Windows.Forms.Timer object is very simple. You tell it how frequent to set the ticks, set it to enabled or disabled, and call Start() to kick it off. The Timer itself doesn't keep track of how long it has been going, you do that by adding an event handler for the Tick event. You do that as seen on line 5 below, by calling add_tick() on the Timer object and passing it a script block that will be called every time the event fires. As far as I can tell this should work for any Windows.Forms object, calling add_event(), where "event" is the name of the event you are adding a handler for. The interval is in miliseconds, so in this case
the scriptblock $timer1_OnTick will be called once every second.
I went ahead and gathered the relevant lines in one place below so it's easier to see what I did. They're kind of spread around in the actual script.
- $timer1 = New-Object System.Windows.Forms.Timer
- $timer1.Enabled = $true
- $timer1.Start()
- $timer1.Interval = 1000
- $timer1.add_tick($timer1_OnTick)