From 20e55efc259d03be055e734d6fd46d66a1ee4bfe Mon Sep 17 00:00:00 2001 From: Baipyrus Date: Sat, 31 Aug 2024 18:03:05 +0200 Subject: [PATCH] set icon according to system proxy --- run.ps1 | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/run.ps1 b/run.ps1 index 21cb41e..d3e63d8 100644 --- a/run.ps1 +++ b/run.ps1 @@ -1,3 +1,6 @@ +# Get inetcpl proxy settings +$settings = Get-ItemProperty -Path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Internet Settings'; + # Load required assemblies for Windows Forms Add-Type -AssemblyName System.Windows.Forms Add-Type -AssemblyName System.Drawing @@ -5,7 +8,11 @@ Add-Type -AssemblyName System.Drawing # Create a new NotifyIcon $trayIcon = New-Object System.Windows.Forms.NotifyIcon # Use a default application icon -$trayIcon.Icon = './assets/ICON_Disabled.ico' +$trayIcon.Icon = if ($settings.proxyEnable) +{ "./assets/ICON_Enabled.ico" +} else +{ "./assets/ICON_Disabled.ico" +} $trayIcon.Text = 'ProxySwitcher' $trayIcon.Visible = $true