enhance toggle logics

- cleanup Invoke-WPFToggle.ps1
- add attributes member to tweaks
- add "eprestart" for restart explorer to attributes.
- removed restart explorer logics from existing toggles.
- add restart explorer logics to Invoke-WPFToggle.ps1 depending on attribute content
This commit is contained in:
MyDrift 2024-08-06 12:32:56 +02:00
parent 49100e1dd6
commit facaf8612a
4 changed files with 27 additions and 21 deletions

View File

@ -3052,6 +3052,7 @@
"Content": "Dark Theme for Windows", "Content": "Dark Theme for Windows",
"Description": "Enable/Disable Dark Mode.", "Description": "Enable/Disable Dark Mode.",
"category": "Customize Preferences", "category": "Customize Preferences",
"attributes": "epRestart",
"panel": "2", "panel": "2",
"Order": "a100_", "Order": "a100_",
"Type": "Toggle" "Type": "Toggle"
@ -3084,6 +3085,7 @@
"Content": "Snap Window", "Content": "Snap Window",
"Description": "If enabled you can align windows by dragging them. | Relogin Required", "Description": "If enabled you can align windows by dragging them. | Relogin Required",
"category": "Customize Preferences", "category": "Customize Preferences",
"attributes": "epRestart",
"panel": "2", "panel": "2",
"Order": "a104_", "Order": "a104_",
"Type": "Toggle" "Type": "Toggle"
@ -3092,6 +3094,7 @@
"Content": "Snap Assist Flyout", "Content": "Snap Assist Flyout",
"Description": "If enabled then Snap preview is disabled when maximize button is hovered.", "Description": "If enabled then Snap preview is disabled when maximize button is hovered.",
"category": "Customize Preferences", "category": "Customize Preferences",
"attributes": "epRestart",
"panel": "2", "panel": "2",
"Order": "a105_", "Order": "a105_",
"Type": "Toggle" "Type": "Toggle"
@ -3100,6 +3103,7 @@
"Content": "Snap Assist Suggestion", "Content": "Snap Assist Suggestion",
"Description": "If enabled then you will get suggestions to snap other applications in the left over spaces.", "Description": "If enabled then you will get suggestions to snap other applications in the left over spaces.",
"category": "Customize Preferences", "category": "Customize Preferences",
"attributes": "epRestart",
"panel": "2", "panel": "2",
"Order": "a106_", "Order": "a106_",
"Type": "Toggle" "Type": "Toggle"

View File

@ -15,11 +15,9 @@ function Invoke-WinUtilSnapFlyout {
Write-Host "Disabling Snap Assist Flyout On startup" Write-Host "Disabling Snap Assist Flyout On startup"
$value = 0 $value = 0
} }
# taskkill.exe /F /IM "explorer.exe"
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
taskkill.exe /F /IM "explorer.exe"
Set-ItemProperty -Path $Path -Name EnableSnapAssistFlyout -Value $value Set-ItemProperty -Path $Path -Name EnableSnapAssistFlyout -Value $value
Start-Process "explorer.exe"
} }
Catch [System.Security.SecurityException] { Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"

View File

@ -17,9 +17,7 @@ function Invoke-WinUtilSnapSuggestion {
} }
# taskkill.exe /F /IM "explorer.exe" # taskkill.exe /F /IM "explorer.exe"
$Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced"
taskkill.exe /F /IM "explorer.exe"
Set-ItemProperty -Path $Path -Name SnapAssist -Value $value Set-ItemProperty -Path $Path -Name SnapAssist -Value $value
Start-Process "explorer.exe"
} }
Catch [System.Security.SecurityException] { Catch [System.Security.SecurityException] {
Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception" Write-Warning "Unable to set $Path\$Name to $Value due to a Security Exception"

View File

@ -15,23 +15,29 @@ function Invoke-WPFToggle {
# Use this to get the name of the button # Use this to get the name of the button
#[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info") #[System.Windows.MessageBox]::Show("$Button","Chris Titus Tech's Windows Utility","OK","Info")
$ToggleStatus = (Get-WinUtilToggleStatus $Button)
Switch -Wildcard ($Button){ Switch -Wildcard ($Button){
"WPFToggleDarkMode" {Invoke-WinUtilDarkMode -DarkMoveEnabled $(Get-WinUtilToggleStatus WPFToggleDarkMode)} "WPFToggleDarkMode" {Invoke-WinUtilDarkMode $ToggleStatus}
"WPFToggleBingSearch" {Invoke-WinUtilBingSearch $(Get-WinUtilToggleStatus WPFToggleBingSearch)} "WPFToggleBingSearch" {Invoke-WinUtilBingSearch $ToggleStatus}
"WPFToggleNumLock" {Invoke-WinUtilNumLock $(Get-WinUtilToggleStatus WPFToggleNumLock)} "WPFToggleNumLock" {Invoke-WinUtilNumLock $ToggleStatus}
"WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $(Get-WinUtilToggleStatus WPFToggleVerboseLogon)} "WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $ToggleStatus}
"WPFToggleShowExt" {Invoke-WinUtilShowExt $(Get-WinUtilToggleStatus WPFToggleShowExt)} "WPFToggleShowExt" {Invoke-WinUtilShowExt $ToggleStatus}
"WPFToggleSnapWindow" {Invoke-WinUtilSnapWindow $(Get-WinUtilToggleStatus WPFToggleSnapWindow)} "WPFToggleSnapWindow" {Invoke-WinUtilSnapWindow $ToggleStatus}
"WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $(Get-WinUtilToggleStatus WPFToggleSnapFlyout)} "WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $ToggleStatus}
"WPFToggleSnapSuggestion" {Invoke-WinUtilSnapSuggestion $(Get-WinUtilToggleStatus WPFToggleSnapSuggestion)} "WPFToggleSnapSuggestion" {Invoke-WinUtilSnapSuggestion $ToggleStatus}
"WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $(Get-WinUtilToggleStatus WPFToggleMouseAcceleration)} "WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $ToggleStatus}
"WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $(Get-WinUtilToggleStatus WPFToggleStickyKeys)} "WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $ToggleStatus}
"WPFToggleTaskbarWidgets" {Invoke-WinUtilTaskbarWidgets $(Get-WinUtilToggleStatus WPFToggleTaskbarWidgets)} "WPFToggleTaskbarWidgets" {Invoke-WinUtilTaskbarWidgets $ToggleStatus}
"WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $(Get-WinUtilToggleStatus WPFToggleTaskbarSearch)} "WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $ToggleStatus}
"WPFToggleTaskView" {Invoke-WinUtilTaskView $(Get-WinUtilToggleStatus WPFToggleTaskView)} "WPFToggleTaskView" {Invoke-WinUtilTaskView $ToggleStatus}
"WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $(Get-WinUtilToggleStatus WPFToggleHiddenFiles)} "WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $ToggleStatus}
"WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $(Get-WinUtilToggleStatus WPFToggleTaskbarAlignment)} "WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $ToggleStatus}
"WPFToggleDetailedBSoD" {Invoke-WinUtilDetailedBSoD $(Get-WinUtilToggleStatus WPFToggleDetailedBSoD)} "WPFToggleDetailedBSoD" {Invoke-WinUtilDetailedBSoD $ToggleStatus}
}
if ($sync.configs.tweaks.$($button).attributes -contains "epRestart") {
taskkill.exe /F /IM "explorer.exe"
Start-Process "explorer.exe"
} }
} }