From a8837ae3ab8b861255bec4e9c6edc63b77527d32 Mon Sep 17 00:00:00 2001 From: rad Date: Sat, 12 Oct 2024 23:56:01 -0400 Subject: [PATCH 1/3] feat: GUI script for accessibility shortcuts --- .../ScriptWrappers/AccessabilityShortcuts.ps1 | 118 ++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessabilityShortcuts.ps1 diff --git a/src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessabilityShortcuts.ps1 b/src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessabilityShortcuts.ps1 new file mode 100644 index 0000000000..be6e337412 --- /dev/null +++ b/src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessabilityShortcuts.ps1 @@ -0,0 +1,118 @@ +[CmdletBinding()] +param() + +function Test-Admin { + $currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() + $principal = New-Object Security.Principal.WindowsPrincipal($currentIdentity) + return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + +if (-not (Test-Admin)) { + Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs + exit +} + +Add-Type -AssemblyName System.Windows.Forms +Add-Type -AssemblyName System.Drawing + +$form = New-Object System.Windows.Forms.Form +$form.Text = "Accessibility Shortcuts" +$form.Size = New-Object System.Drawing.Size(400, 400) +$form.StartPosition = "CenterScreen" + +function Toggle-Process { + param ( + [string]$processName, + [scriptblock]$startCommand + ) + $process = Get-Process -Name $processName -ErrorAction SilentlyContinue + if ($process) { + Stop-Process -Name $processName -Force + Start-Sleep -Milliseconds 500 + } else { + & $startCommand + } +} + +# Dark Mode/Light Mode Toggle +function dark_mode { + $form.BackColor = [System.Drawing.Color]::FromArgb(26, 26, 26) + $form.ForeColor = [System.Drawing.Color]::White + foreach ($control in $form.Controls) { + if ($control.GetType().Name -eq "Button") { + $control.BackColor = [System.Drawing.Color]::FromArgb(26, 26, 26) + $control.ForeColor = [System.Drawing.Color]::White + } + } +} + +function light_mode { + $form.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240) + $form.ForeColor = [System.Drawing.Color]::Black + foreach ($control in $form.Controls) { + if ($control.GetType().Name -eq "Button") { + $control.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240) + $control.ForeColor = [System.Drawing.Color]::Black + } + } +} + +$registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" +$keyName = "AppsUseLightTheme" +function check_system_theme { + if (((Get-ItemProperty -Path $registryPath -Name $keyName).$keyName) -eq 0) { + dark_mode + $toggleBtn.Text = "Light Mode" + } else { + light_mode + $toggleBtn.Text = "Dark Mode" + } +} + +$toggleBtn = New-Object System.Windows.Forms.Button +$toggleBtn.Location = New-Object System.Drawing.Point(300, 10) +$toggleBtn.Size = New-Object System.Drawing.Size(80, 23) +$toggleBtn.Add_Click({ + if ($toggleBtn.Text -eq "Dark Mode") { + $toggleBtn.Text = "Light Mode" + dark_mode + } else { + $toggleBtn.Text = "Dark Mode" + light_mode + } +}) +$form.Controls.Add($toggleBtn) + +check_system_theme + +$buttons = @( + @{Text = "Toggle Narrator"; Shortcut = "Ctrl + Win + Enter"; Handler = { + Toggle-Process -processName "Narrator" -startCommand { Start-Process "Narrator.exe" } + }}, + @{Text = "Toggle Magnifier"; Shortcut = "Win + Plus/Minus"; Handler = { + Toggle-Process -processName "Magnify" -startCommand { Start-Process "Magnify.exe" } + }}, + @{Text = "Toggle High Contrast"; Shortcut = "Alt + Shift + Print Screen"; Handler = { + Start-Process "ms-settings:easeofaccess-highcontrast" + }}, + @{Text = "Open/Close On-Screen Keyboard"; Shortcut = "Win + Ctrl + O"; Handler = { + Toggle-Process -processName "osk" -startCommand { Start-Process "osk.exe" } + }}, + @{Text = "Sticky Keys Settings"; Shortcut = "Shift Key (pressed 5 times)"; Handler = { + Start-Process "ms-settings:easeofaccess-keyboard" + }} +) + +$yPos = 50 +foreach ($buttonInfo in $buttons) { + $button = New-Object System.Windows.Forms.Button + $button.Size = New-Object System.Drawing.Size(350, 40) + $button.Location = New-Object System.Drawing.Point(20, $yPos) + $button.Text = "$($buttonInfo.Text) ($($buttonInfo.Shortcut))" + $button.Add_Click($buttonInfo.Handler) + $form.Controls.Add($button) + $yPos += 50 +} + +$form.Topmost = $true +[void]$form.ShowDialog() \ No newline at end of file From 68fedb98d5a7ef4b43e9f68b7ca835e93f112058 Mon Sep 17 00:00:00 2001 From: rad Date: Sat, 12 Oct 2024 23:58:10 -0400 Subject: [PATCH 2/3] feat: GUI script for accessibility shortcuts --- .../4. Interface Tweaks/Accessibility Shortcuts.cmd | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd diff --git a/src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd b/src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd new file mode 100644 index 0000000000..fc2a99b383 --- /dev/null +++ b/src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd @@ -0,0 +1,9 @@ +@echo off +set "script=%windir%\AtlasModules\Scripts\ScriptWrappers\AccessibilityShortcuts.ps1" +if not exist "%script%" ( + echo Script not found. + echo "%script%" + pause + exit /b 1 +) +powershell -EP Bypass -NoP ^& """$env:script""" %* \ No newline at end of file From 22ad1fb7e0d2e1f40d8ffab593f161853daf7b81 Mon Sep 17 00:00:00 2001 From: rad Date: Sun, 13 Oct 2024 00:01:20 -0400 Subject: [PATCH 3/3] chore: fix typo in name --- .../Accessibility Shortcuts.cmd | 16 +- ...ortcuts.ps1 => AccessibilityShortcuts.ps1} | 234 +++++++++--------- 2 files changed, 125 insertions(+), 125 deletions(-) rename src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/{AccessabilityShortcuts.ps1 => AccessibilityShortcuts.ps1} (97%) diff --git a/src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd b/src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd index fc2a99b383..9a383d2ee5 100644 --- a/src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd +++ b/src/playbook/Executables/AtlasDesktop/4. Interface Tweaks/Accessibility Shortcuts.cmd @@ -1,9 +1,9 @@ -@echo off -set "script=%windir%\AtlasModules\Scripts\ScriptWrappers\AccessibilityShortcuts.ps1" -if not exist "%script%" ( - echo Script not found. - echo "%script%" - pause - exit /b 1 -) +@echo off +set "script=%windir%\AtlasModules\Scripts\ScriptWrappers\AccessibilityShortcuts.ps1" +if not exist "%script%" ( + echo Script not found. + echo "%script%" + pause + exit /b 1 +) powershell -EP Bypass -NoP ^& """$env:script""" %* \ No newline at end of file diff --git a/src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessabilityShortcuts.ps1 b/src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessibilityShortcuts.ps1 similarity index 97% rename from src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessabilityShortcuts.ps1 rename to src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessibilityShortcuts.ps1 index be6e337412..0983d6b85c 100644 --- a/src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessabilityShortcuts.ps1 +++ b/src/playbook/Executables/AtlasModules/Scripts/ScriptWrappers/AccessibilityShortcuts.ps1 @@ -1,118 +1,118 @@ -[CmdletBinding()] -param() - -function Test-Admin { - $currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() - $principal = New-Object Security.Principal.WindowsPrincipal($currentIdentity) - return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) -} - -if (-not (Test-Admin)) { - Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs - exit -} - -Add-Type -AssemblyName System.Windows.Forms -Add-Type -AssemblyName System.Drawing - -$form = New-Object System.Windows.Forms.Form -$form.Text = "Accessibility Shortcuts" -$form.Size = New-Object System.Drawing.Size(400, 400) -$form.StartPosition = "CenterScreen" - -function Toggle-Process { - param ( - [string]$processName, - [scriptblock]$startCommand - ) - $process = Get-Process -Name $processName -ErrorAction SilentlyContinue - if ($process) { - Stop-Process -Name $processName -Force - Start-Sleep -Milliseconds 500 - } else { - & $startCommand - } -} - -# Dark Mode/Light Mode Toggle -function dark_mode { - $form.BackColor = [System.Drawing.Color]::FromArgb(26, 26, 26) - $form.ForeColor = [System.Drawing.Color]::White - foreach ($control in $form.Controls) { - if ($control.GetType().Name -eq "Button") { - $control.BackColor = [System.Drawing.Color]::FromArgb(26, 26, 26) - $control.ForeColor = [System.Drawing.Color]::White - } - } -} - -function light_mode { - $form.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240) - $form.ForeColor = [System.Drawing.Color]::Black - foreach ($control in $form.Controls) { - if ($control.GetType().Name -eq "Button") { - $control.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240) - $control.ForeColor = [System.Drawing.Color]::Black - } - } -} - -$registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" -$keyName = "AppsUseLightTheme" -function check_system_theme { - if (((Get-ItemProperty -Path $registryPath -Name $keyName).$keyName) -eq 0) { - dark_mode - $toggleBtn.Text = "Light Mode" - } else { - light_mode - $toggleBtn.Text = "Dark Mode" - } -} - -$toggleBtn = New-Object System.Windows.Forms.Button -$toggleBtn.Location = New-Object System.Drawing.Point(300, 10) -$toggleBtn.Size = New-Object System.Drawing.Size(80, 23) -$toggleBtn.Add_Click({ - if ($toggleBtn.Text -eq "Dark Mode") { - $toggleBtn.Text = "Light Mode" - dark_mode - } else { - $toggleBtn.Text = "Dark Mode" - light_mode - } -}) -$form.Controls.Add($toggleBtn) - -check_system_theme - -$buttons = @( - @{Text = "Toggle Narrator"; Shortcut = "Ctrl + Win + Enter"; Handler = { - Toggle-Process -processName "Narrator" -startCommand { Start-Process "Narrator.exe" } - }}, - @{Text = "Toggle Magnifier"; Shortcut = "Win + Plus/Minus"; Handler = { - Toggle-Process -processName "Magnify" -startCommand { Start-Process "Magnify.exe" } - }}, - @{Text = "Toggle High Contrast"; Shortcut = "Alt + Shift + Print Screen"; Handler = { - Start-Process "ms-settings:easeofaccess-highcontrast" - }}, - @{Text = "Open/Close On-Screen Keyboard"; Shortcut = "Win + Ctrl + O"; Handler = { - Toggle-Process -processName "osk" -startCommand { Start-Process "osk.exe" } - }}, - @{Text = "Sticky Keys Settings"; Shortcut = "Shift Key (pressed 5 times)"; Handler = { - Start-Process "ms-settings:easeofaccess-keyboard" - }} -) - -$yPos = 50 -foreach ($buttonInfo in $buttons) { - $button = New-Object System.Windows.Forms.Button - $button.Size = New-Object System.Drawing.Size(350, 40) - $button.Location = New-Object System.Drawing.Point(20, $yPos) - $button.Text = "$($buttonInfo.Text) ($($buttonInfo.Shortcut))" - $button.Add_Click($buttonInfo.Handler) - $form.Controls.Add($button) - $yPos += 50 -} - -$form.Topmost = $true +[CmdletBinding()] +param() + +function Test-Admin { + $currentIdentity = [Security.Principal.WindowsIdentity]::GetCurrent() + $principal = New-Object Security.Principal.WindowsPrincipal($currentIdentity) + return $principal.IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator) +} + +if (-not (Test-Admin)) { + Start-Process -FilePath "powershell.exe" -ArgumentList "-NoProfile -ExecutionPolicy Bypass -File `"$PSCommandPath`"" -Verb RunAs + exit +} + +Add-Type -AssemblyName System.Windows.Forms +Add-Type -AssemblyName System.Drawing + +$form = New-Object System.Windows.Forms.Form +$form.Text = "Accessibility Shortcuts" +$form.Size = New-Object System.Drawing.Size(400, 400) +$form.StartPosition = "CenterScreen" + +function Toggle-Process { + param ( + [string]$processName, + [scriptblock]$startCommand + ) + $process = Get-Process -Name $processName -ErrorAction SilentlyContinue + if ($process) { + Stop-Process -Name $processName -Force + Start-Sleep -Milliseconds 500 + } else { + & $startCommand + } +} + +# Dark Mode/Light Mode Toggle +function dark_mode { + $form.BackColor = [System.Drawing.Color]::FromArgb(26, 26, 26) + $form.ForeColor = [System.Drawing.Color]::White + foreach ($control in $form.Controls) { + if ($control.GetType().Name -eq "Button") { + $control.BackColor = [System.Drawing.Color]::FromArgb(26, 26, 26) + $control.ForeColor = [System.Drawing.Color]::White + } + } +} + +function light_mode { + $form.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240) + $form.ForeColor = [System.Drawing.Color]::Black + foreach ($control in $form.Controls) { + if ($control.GetType().Name -eq "Button") { + $control.BackColor = [System.Drawing.Color]::FromArgb(240, 240, 240) + $control.ForeColor = [System.Drawing.Color]::Black + } + } +} + +$registryPath = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize" +$keyName = "AppsUseLightTheme" +function check_system_theme { + if (((Get-ItemProperty -Path $registryPath -Name $keyName).$keyName) -eq 0) { + dark_mode + $toggleBtn.Text = "Light Mode" + } else { + light_mode + $toggleBtn.Text = "Dark Mode" + } +} + +$toggleBtn = New-Object System.Windows.Forms.Button +$toggleBtn.Location = New-Object System.Drawing.Point(300, 10) +$toggleBtn.Size = New-Object System.Drawing.Size(80, 23) +$toggleBtn.Add_Click({ + if ($toggleBtn.Text -eq "Dark Mode") { + $toggleBtn.Text = "Light Mode" + dark_mode + } else { + $toggleBtn.Text = "Dark Mode" + light_mode + } +}) +$form.Controls.Add($toggleBtn) + +check_system_theme + +$buttons = @( + @{Text = "Toggle Narrator"; Shortcut = "Ctrl + Win + Enter"; Handler = { + Toggle-Process -processName "Narrator" -startCommand { Start-Process "Narrator.exe" } + }}, + @{Text = "Toggle Magnifier"; Shortcut = "Win + Plus/Minus"; Handler = { + Toggle-Process -processName "Magnify" -startCommand { Start-Process "Magnify.exe" } + }}, + @{Text = "Toggle High Contrast"; Shortcut = "Alt + Shift + Print Screen"; Handler = { + Start-Process "ms-settings:easeofaccess-highcontrast" + }}, + @{Text = "Open/Close On-Screen Keyboard"; Shortcut = "Win + Ctrl + O"; Handler = { + Toggle-Process -processName "osk" -startCommand { Start-Process "osk.exe" } + }}, + @{Text = "Sticky Keys Settings"; Shortcut = "Shift Key (pressed 5 times)"; Handler = { + Start-Process "ms-settings:easeofaccess-keyboard" + }} +) + +$yPos = 50 +foreach ($buttonInfo in $buttons) { + $button = New-Object System.Windows.Forms.Button + $button.Size = New-Object System.Drawing.Size(350, 40) + $button.Location = New-Object System.Drawing.Point(20, $yPos) + $button.Text = "$($buttonInfo.Text) ($($buttonInfo.Shortcut))" + $button.Add_Click($buttonInfo.Handler) + $form.Controls.Add($button) + $yPos += 50 +} + +$form.Topmost = $true [void]$form.ShowDialog() \ No newline at end of file