mirror of
https://github.com/ChrisTitusTech/winutil.git
synced 2024-11-14 22:55:52 -06:00
move logic to json template
- remove Invoke-WPFToggle.ps1 - generalize Get-WinUtilToggleStatus - add bingsearch reg key for testing - use Invoke-WinUtilTweaks for actions - replace Add-Click with checked & unchecked to make undo work
This commit is contained in:
parent
ce1ef2a519
commit
f0afb6735a
@ -3302,6 +3302,15 @@
|
|||||||
"panel": "2",
|
"panel": "2",
|
||||||
"Order": "a101_",
|
"Order": "a101_",
|
||||||
"Type": "Toggle",
|
"Type": "Toggle",
|
||||||
|
"registry": [
|
||||||
|
{
|
||||||
|
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Search",
|
||||||
|
"Name": "BingSearchEnabled",
|
||||||
|
"Value": "0",
|
||||||
|
"OriginalValue": "1",
|
||||||
|
"Type": "DWord"
|
||||||
|
}
|
||||||
|
],
|
||||||
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/BingSearch"
|
"link": "https://christitustech.github.io/winutil/dev/tweaks/Customize-Preferences/BingSearch"
|
||||||
},
|
},
|
||||||
"WPFToggleNumLock": {
|
"WPFToggleNumLock": {
|
||||||
|
@ -13,75 +13,29 @@ Function Get-WinUtilToggleStatus {
|
|||||||
#>
|
#>
|
||||||
|
|
||||||
Param($ToggleSwitch)
|
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
|
|
||||||
return $app -eq 0 -and $system -eq 0
|
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleBingSearch") {
|
|
||||||
$bingsearch = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Search').BingSearchEnabled
|
|
||||||
return $bingsearch -ne 0
|
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleNumLock") {
|
|
||||||
$numlockvalue = (Get-ItemProperty -path 'HKCU:\Control Panel\Keyboard').InitialKeyboardIndicators
|
|
||||||
return $numlockvalue -eq 2
|
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleVerboseLogon") {
|
|
||||||
$VerboseStatusvalue = (Get-ItemProperty -path 'HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System').VerboseStatus
|
|
||||||
return $VerboseStatusvalue -eq 1
|
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleShowExt") {
|
|
||||||
$hideextvalue = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').HideFileExt
|
|
||||||
return $hideextvalue -eq 0
|
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleSnapWindow") {
|
|
||||||
$hidesnap = (Get-ItemProperty -path 'HKCU:\Control Panel\Desktop').WindowArrangementActive
|
|
||||||
return $hidesnap -ne 0
|
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleSnapFlyout") {
|
|
||||||
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').EnableSnapAssistFlyout
|
|
||||||
return $hidesnap -ne 0
|
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleSnapSuggestion") {
|
|
||||||
$hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').SnapAssist
|
|
||||||
return $hidesnap -ne 0
|
|
||||||
}
|
|
||||||
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
|
|
||||||
|
|
||||||
return $MouseSpeed -eq 1 -and $MouseThreshold1 -eq 6 -and $MouseThreshold2 -eq 10
|
$ToggleSwitchReg = $sync.configs.tweaks.$ToggleSwitch.registry
|
||||||
}
|
|
||||||
if($ToggleSwitch -eq "WPFToggleTaskbarSearch") {
|
|
||||||
$SearchButton = (Get-ItemProperty -path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Search").SearchboxTaskbarMode
|
|
||||||
return $SearchButton -ne 0
|
|
||||||
}
|
|
||||||
if ($ToggleSwitch -eq "WPFToggleStickyKeys") {
|
|
||||||
$StickyKeys = (Get-ItemProperty -path 'HKCU:\Control Panel\Accessibility\StickyKeys').Flags
|
|
||||||
return $StickyKeys -ne 58
|
|
||||||
}
|
|
||||||
if ($ToggleSwitch -eq "WPFToggleTaskView") {
|
|
||||||
$TaskView = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').ShowTaskViewButton
|
|
||||||
return $TaskView -ne 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ToggleSwitch -eq "WPFToggleHiddenFiles") {
|
if ($ToggleSwitchReg) {
|
||||||
$HiddenFiles = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').Hidden
|
$count = 0
|
||||||
return $HiddenFiles -ne 0
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($ToggleSwitch -eq "WPFToggleTaskbarWidgets") {
|
foreach ($regentry in $ToggleSwitchReg) {
|
||||||
$TaskbarWidgets = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskBarDa
|
$regstate = (Get-ItemProperty -path $($regentry.Path)).$($regentry.Name)
|
||||||
return $TaskbarWidgets -ne 0
|
if ($regstate -eq $regentry.Value) {
|
||||||
}
|
$count += 1
|
||||||
if ($ToggleSwitch -eq "WPFToggleTaskbarAlignment") {
|
} else {
|
||||||
$TaskbarAlignment = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskbarAl
|
write-debug "$($regentry.Name) is false (state: $regstate, value: $($regentry.Value), original: $($regentry.OriginalValue))"
|
||||||
return $TaskbarAlignment -ne 0
|
}
|
||||||
}
|
}
|
||||||
if ($ToggleSwitch -eq "WPFToggleDetailedBSoD") {
|
|
||||||
$DetailedBSoD1 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisplayParameters
|
if ($count -eq $ToggleSwitchReg.Count) {
|
||||||
$DetailedBSoD2 = (Get-ItemProperty -Path 'HKLM:\SYSTEM\CurrentControlSet\Control\CrashControl').DisableEmoticon
|
write-debug "$($ToggleSwitchReg.Name) is true (count: $count)"
|
||||||
return !(($DetailedBSoD1 -eq 0) -or ($DetailedBSoD2 -eq 0) -or !$DetailedBSoD1 -or !$DetailedBSoD2)
|
return $true
|
||||||
|
} else {
|
||||||
|
write-debug "$($ToggleSwitchReg.Name) is false (count: $count)"
|
||||||
|
return $false
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return $false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,10 @@ function Invoke-WinUtilTweaks {
|
|||||||
$KeepServiceStartup = $true
|
$KeepServiceStartup = $true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if ($Checkbox -contains "Toggle") {
|
||||||
|
$CheckBox = $sync.configs.tweaks.$CheckBox
|
||||||
|
}
|
||||||
|
|
||||||
Write-Debug "Tweaks: $($CheckBox)"
|
Write-Debug "Tweaks: $($CheckBox)"
|
||||||
if($undo) {
|
if($undo) {
|
||||||
$Values = @{
|
$Values = @{
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
function Invoke-WPFToggle {
|
|
||||||
|
|
||||||
<#
|
|
||||||
|
|
||||||
.SYNOPSIS
|
|
||||||
Invokes the scriptblock for the given toggle
|
|
||||||
|
|
||||||
.PARAMETER Button
|
|
||||||
The name of the toggle to invoke
|
|
||||||
|
|
||||||
#>
|
|
||||||
|
|
||||||
Param ([string]$Button)
|
|
||||||
|
|
||||||
# Use this to get the name of the button
|
|
||||||
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
|
|
||||||
|
|
||||||
$ToggleStatus = (Get-WinUtilToggleStatus $Button)
|
|
||||||
|
|
||||||
Switch -Wildcard ($Button) {
|
|
||||||
|
|
||||||
"WPFToggleDarkMode" {Invoke-WinUtilDarkMode $ToggleStatus}
|
|
||||||
"WPFToggleBingSearch" {Invoke-WinUtilBingSearch $ToggleStatus}
|
|
||||||
"WPFToggleNumLock" {Invoke-WinUtilNumLock $ToggleStatus}
|
|
||||||
"WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $ToggleStatus}
|
|
||||||
"WPFToggleShowExt" {Invoke-WinUtilShowExt $ToggleStatus}
|
|
||||||
"WPFToggleSnapWindow" {Invoke-WinUtilSnapWindow $ToggleStatus}
|
|
||||||
"WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $ToggleStatus}
|
|
||||||
"WPFToggleSnapSuggestion" {Invoke-WinUtilSnapSuggestion $ToggleStatus}
|
|
||||||
"WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $ToggleStatus}
|
|
||||||
"WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $ToggleStatus}
|
|
||||||
"WPFToggleTaskbarWidgets" {Invoke-WinUtilTaskbarWidgets $ToggleStatus}
|
|
||||||
"WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $ToggleStatus}
|
|
||||||
"WPFToggleTaskView" {Invoke-WinUtilTaskView $ToggleStatus}
|
|
||||||
"WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $ToggleStatus}
|
|
||||||
"WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $ToggleStatus}
|
|
||||||
"WPFToggleDetailedBSoD" {Invoke-WinUtilDetailedBSoD $ToggleStatus}
|
|
||||||
}
|
|
||||||
}
|
|
@ -192,11 +192,16 @@ function Invoke-WPFUIElements {
|
|||||||
|
|
||||||
$sync[$entryInfo.Name] = $checkBox
|
$sync[$entryInfo.Name] = $checkBox
|
||||||
|
|
||||||
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $sync[$entryInfo.Name].Name
|
$sync[$entryInfo.Name].IsChecked = Get-WinUtilToggleStatus $entryInfo.Name
|
||||||
|
|
||||||
$sync[$entryInfo.Name].Add_Click({
|
$sync[$entryInfo.Name].Add_Checked({
|
||||||
[System.Object]$Sender = $args[0]
|
[System.Object]$Sender = $args[0]
|
||||||
Invoke-WPFToggle $Sender.name
|
Invoke-WinUtilTweaks $sender.name
|
||||||
|
})
|
||||||
|
|
||||||
|
$sync[$entryInfo.Name].Add_Unchecked({
|
||||||
|
[System.Object]$Sender = $args[0]
|
||||||
|
Invoke-WinUtiltweaks $sender.name -undo $true
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user