Last active
October 9, 2022 17:54
-
-
Save pinuke/6368e9d9fc85106ed0a573922d986744 to your computer and use it in GitHub Desktop.
PowerShell Quick Tray - Creating a SysTray Icon
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add-Type –AssemblyName System.Windows.Forms #,PresentationFramework - We won't need this until the next project log | |
$appContext = New-Object System.Windows.Forms.ApplicationContext | |
$executable = "$env:SystemRoot\system32\WindowsPowerShell\v1.0\powershell.exe" | |
$icon = [System.Drawing.Icon]::ExtractAssociatedIcon( $executable ) | |
$QuickTray = New-Object System.Windows.Forms.NotifyIcon | |
$QuickTray.Icon = $icon | |
$QuickTray.Text = "PowerShell Quick Tray" | |
$QuickTray.Add_MouseDown({ | |
if ($_.Button -eq [System.Windows.Forms.MouseButtons]::Right) | |
{ | |
[System.Windows.MessageBox]::Show("Hello World!") | |
} | |
}) | |
$QuickTray.Visible = $true | |
[void][System.Windows.Forms.Application]::Run($appContext) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment