In this post I showed how to set a count down timer
http://msmvps.com/blogs/richardsiddaway/archive/2011/08/02/a-count-down-timer.aspx
but what if you want to go the other way i.e. see how long something takes
The count down function can be modified
Import-Module ShowUI function timegone { $ts = (Get-Date) - $start $time = $ts.ToString() -split "\." if ($ts.Hours -eq 0) { $time[0].Substring(3,5) } else { $time } } $start = Get-Date $windowAttributes = @{ WindowStartupLocation = "CenterScreen" SizeToContent = "WidthAndHeight" WindowStyle = "None" Background = "Transparent " On_MouseRightButtonDown = { Close-Control} On_MouseLeftButtonDown = { $_.Handled = $true;$window.DragMove() } On_Loaded = { Register-PowerShellCommand -ScriptBlock { $window.Content.Content = timegone } -Run -In "0:0:0.5" } } $labelAttributes = @{ Content = timegone FontFamily = "Impact, Arial" FontWeight = 800 FontSize = 30 } New-Window @windowAttributes -AllowsTransparency -Show { Label @labelAttributes -Name Clock -Foreground ( LinearGradientBrush $( GradientStop -Color Red -Offset 1 GradientStop -Color Orange -Offset 0.85 GradientStop -Color Yellow -Offset 0.7 GradientStop -Color Green -Offset 0.55 GradientStop -Color Blue -Offset 0.4 GradientStop -Color Indigo -Offset 0.2 GradientStop -Color Violet -Offset 0 ) ) }
The main change is that our starting point is now. We then get the current time, subtract our starting point and we have the elapsed time.
Display as before