Skip to content

Instantly share code, notes, and snippets.

@nyanhp
Created March 31, 2022 12:50
Show Gist options
  • Save nyanhp/291d248f2a1f045df1206ec202c55f14 to your computer and use it in GitHub Desktop.
Save nyanhp/291d248f2a1f045df1206ec202c55f14 to your computer and use it in GitHub Desktop.
Tray Icon with PowerShell
# Tray Icon requires Assemblies
Add-Type -AssemblyName System.Drawing
Add-Type -AssemblyName System.Windows.Forms
$tipTimeout = New-TimeSpan -Seconds 10
$trayIcon = [System.Windows.Forms.NotifyIcon]::new()
$trayIcon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon((Get-Process -Id $PID).Path)
$trayIcon.Text = "It Does things";
$trayIcon.Visible = $true;
$trayIcon.BalloonTipTitle = "Hi $env:USERNAME!";
$trayIcon.BalloonTipText = "This is a content text";
$trayIcon.ShowBalloonTip($tipTimeout.TotalMilliseconds);
# Bereinigen
$trayIcon.Dispose()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment