winutil/functions/private/Get-WinUtilToggleStatus.ps1
Chris Titus 4773cd6d2b
Test 2023 02 02 (#1556)
* Fix config tab (#1547)

The JSON is poorly formatted. In my machine this resolved the issue

* Compile Winutil

* Add toggle "sticky keys" (#1546)

Adds a toggle to enable/disable sticky keys

* added miniconda, temurin, presentmon and pyenv-win (#1542)

* Compile Winutil

---------

Co-authored-by: Yuri Gabriel <97139700+Yuuh15@users.noreply.github.com>
Co-authored-by: ChrisTitusTech <ChrisTitusTech@users.noreply.github.com>
Co-authored-by: Jakub Krojec <jakub.krojec@gmail.com>
2024-02-03 11:42:14 -06:00

92 lines
3.0 KiB
PowerShell

Function Get-WinUtilToggleStatus {
<#
.SYNOPSIS
Pulls the registry keys for the given toggle switch and checks whether the toggle should be checked or unchecked
.PARAMETER ToggleSwitch
The name of the toggle to check
.OUTPUTS
Boolean to set the toggle's status to
#>
Param($ToggleSwitch)
if($ToggleSwitch -eq "WPFToggleDarkMode"){
$app = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').AppsUseLightTheme
$system = (Get-ItemProperty -path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Themes\Personalize').SystemUsesLightTheme
if($app -eq 0 -and $system -eq 0){
return $true
}
else{
return $false
}
}
if($ToggleSwitch -eq "WPFToggleBingSearch"){
$bingsearch = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search').BingSearchEnabled
if($bingsearch -eq 0){
return $false
}
else{
return $true
}
}
if($ToggleSwitch -eq "WPFToggleNumLock"){
$numlockvalue = (Get-ItemProperty -path 'HKCU:\Control Panel\Keyboard').InitialKeyboardIndicators
if($numlockvalue -eq 2){
return $true
}
else{
return $false
}
}
if($ToggleSwitch -eq "WPFToggleVerboseLogon"){
$VerboseStatusvalue = (Get-ItemProperty -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System').VerboseStatus
if($VerboseStatusvalue -eq 1){
return $true
}
else{
return $false
}
}
if($ToggleSwitch -eq "WPFToggleShowExt"){
$hideextvalue = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').HideFileExt
if($hideextvalue -eq 0){
return $true
}
else{
return $false
}
}
if($ToggleSwitch -eq "WPFToggleSnapFlyout"){
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').EnableSnapAssistFlyout
if($hidesnap -eq 0){
return $false
}
else{
return $true
}
}
if($ToggleSwitch -eq "WPFToggleMouseAcceleration"){
$MouseSpeed = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseSpeed
$MouseThreshold1 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold1
$MouseThreshold2 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold2
if($MouseSpeed -eq 1 -and $MouseThreshold1 -eq 6 -and $MouseThreshold2 -eq 10){
return $true
}
else{
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
}
}
}