Skip to content

Commit

Permalink
Add toggle "sticky keys" (#1546)
Browse files Browse the repository at this point in the history
Adds a toggle to enable/disable sticky keys
  • Loading branch information
Yuuh15 authored Feb 3, 2024
1 parent 7eadc88 commit 2911893
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 0 deletions.
8 changes: 8 additions & 0 deletions config/tweaks.json
Original file line number Diff line number Diff line change
Expand Up @@ -2602,6 +2602,14 @@
"Order": "a066_",
"Type": "Toggle"
},
"WPFToggleStickyKeys": {
"Content": "Sticky Keys",
"Description": "If Enabled then Sticky Keys is activated - Sticky keys is an accessibility feature of some graphical user interfaces which assists users who have physical disabilities or help users reduce repetitive strain injury.",
"category": "Customize Preferences",
"panel": "2",
"Order": "a067_",
"Type": "Toggle"
},
"WPFchangedns": {
"Content": "DNS",
"category": "z__Advanced Tweaks - CAUTION",
Expand Down
9 changes: 9 additions & 0 deletions functions/private/Get-WinUtilToggleStatus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,13 @@ Function Get-WinUtilToggleStatus {
return $false
}
}
if ($ToggleSwitch -eq "WPFToggleStickyKeys") {
$StickyKeys = (Get-ItemProperty -path 'HKCU:\Control Panel\Accessibility\StickyKeys').Flags
if($StickyKeys -eq 58){
return $false
}
else{
return $true
}
}
}
31 changes: 31 additions & 0 deletions functions/private/Invoke-WinUtilStickyKeys
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
Function Invoke-WinUtilStickyKeys {
<#
.SYNOPSIS
Disables/Enables Sticky Keyss on startup
.PARAMETER Enabled
Indicates whether to enable or disable Sticky Keys on startup
#>
Param($Enabled)
Try {
if ($Enabled -eq $false){
Write-Host "Enabling Sticky Keys On startup"
$value = 510
}
else {
Write-Host "Disabling Sticky Keys On startup"
$value = 58
}
$Path = "HKCU:\Control Panel\Accessibility\StickyKeys"
Set-ItemProperty -Path $Path -Name Flags -Value $value
}
Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
}
Catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
}
Catch{
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}
1 change: 1 addition & 0 deletions functions/public/Invoke-WPFToggle.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,6 @@ function Invoke-WPFToggle {
"WPFToggleShowExt" {Invoke-WinUtilShowExt $(Get-WinUtilToggleStatus WPFToggleShowExt)}
"WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $(Get-WinUtilToggleStatus WPFToggleSnapFlyout)}
"WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $(Get-WinUtilToggleStatus WPFToggleMouseAcceleration)}
"WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $(Get-WinUtilToggleStatus WPFToggleStickyKeys)}
}
}
49 changes: 49 additions & 0 deletions winutil.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,15 @@ Function Get-WinUtilToggleStatus {
return $false
}
}
if ($ToggleSwitch -eq "WPFToggleStickyKeys") {
$StickyKeys = (Get-ItemProperty -path 'HKCU:\Control Panel\Accessibility\StickyKeys').Flags
if($StickyKeys -eq 58){
return $false
}
else{
return $true
}
}
}
function Get-WinUtilVariables {

Expand Down Expand Up @@ -1672,6 +1681,37 @@ function Invoke-WinUtilSnapFlyout {
Write-Warning $psitem.Exception.StackTrace
}
}
Function Invoke-WinUtilStickyKeys {
<#
.SYNOPSIS
Disables/Enables Sticky Keyss on startup
.PARAMETER Enabled
Indicates whether to enable or disable Sticky Keys on startup
#>
Param($Enabled)
Try {
if ($Enabled -eq $false){
Write-Host "Enabling Sticky Keys On startup"
$value = 510
}
else {
Write-Host "Disabling Sticky Keys On startup"
$value = 58
}
$Path = "HKCU:\Control Panel\Accessibility\StickyKeys"
Set-ItemProperty -Path $Path -Name Flags -Value $value
}
Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"
}
Catch [System.Management.Automation.ItemNotFoundException] {
Write-Warning $psitem.Exception.ErrorRecord
}
Catch{
Write-Warning "Unable to set $Name due to unhandled exception"
Write-Warning $psitem.Exception.StackTrace
}
}
function Invoke-WinUtilTweaks {
<#
Expand Down Expand Up @@ -3905,6 +3945,7 @@ function Invoke-WPFToggle {
"WPFToggleShowExt" {Invoke-WinUtilShowExt $(Get-WinUtilToggleStatus WPFToggleShowExt)}
"WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $(Get-WinUtilToggleStatus WPFToggleSnapFlyout)}
"WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $(Get-WinUtilToggleStatus WPFToggleMouseAcceleration)}
"WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $(Get-WinUtilToggleStatus WPFToggleStickyKeys)}
}
}
function Invoke-WPFtweaksbutton {
Expand Down Expand Up @@ -10618,6 +10659,14 @@ $sync.configs.tweaks = '{
"Order": "a066_",
"Type": "Toggle"
},
"WPFToggleStickyKeys": {
"Content": "Sticky Keys",
"Description": "If Enabled then Sticky Keys is activated - Sticky keys is an accessibility feature of some graphical user interfaces which assists users who have physical disabilities or help users reduce repetitive strain injury.",
"category": "Customize Preferences",
"panel": "2",
"Order": "a067_",
"Type": "Toggle"
},
"WPFchangedns": {
"Content": "DNS",
"category": "z__Advanced Tweaks - CAUTION",
Expand Down

0 comments on commit 2911893

Please sign in to comment.