Richard Siddaway posted A PowerShell Clock using WPF and demonstrated some nice features.
- A windowless window
- Ticking digital clock
- Moving the window by clicking and dragging even though it doesn’t have a border
The ShowUI Code
Here is the ShowUI code. Note the On_* keys in the hash table. They handle the mouse button events and the windows load event where I register a PowerShell script block that executes every half a second. This updates the time and enables the ticking digital clock.
Richard’s solution has the advantage that he can deploy it and it should work on any windows system that has the latest .NET runtime.
My solution requires the ShowUI module to be installed on the target machine.
The advantages to my solution, IMHO, are no XAML, increased value per line of code and it’s all PowerShell.
Check out both solutions and ShowUI.
Import-Module ShowUI $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 = (Get-Date).ToString("T") } -Run -In "0:0:0.5" } } $labelAttributes = @{ Content = (Get-Date).ToString("T") FontFamily = "Impact, Arial" FontWeight = 800 FontSize = 90 } 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 ) ) }
Related Topics
- My “Hello World” video tutorial of ShowUI
- PowerShell, ShowUI and the Twitter API
- Other ShowUI video tutorials from James Brundage, one of the authors of ShowUI



{ 4 trackbacks }
{ 3 comments… read them below or add one }
Why does this ignore font weight/size when I replace -Show with -AsJob?
Thanks Ravi. Can you put that up on the CodePlex site? Then we can get more eyes on it.
Thanks
Doug
Done. http://showui.codeplex.com/discussions/264418
Ravi