From 46f827fe2f25936729c4c294a21c3a59cbe8bed7 Mon Sep 17 00:00:00 2001 From: MyDrift Date: Wed, 28 Aug 2024 19:40:56 +0200 Subject: [PATCH] Toggle logic cleanup (#2527) * 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 * undo attributes --- .../private/Invoke-WinUtilSnapFlyout.ps1 | 2 +- functions/public/Invoke-WPFToggle.ps1 | 34 ++++++++++--------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/functions/private/Invoke-WinUtilSnapFlyout.ps1 b/functions/private/Invoke-WinUtilSnapFlyout.ps1 index bfb83c31..39d1335b 100644 --- a/functions/private/Invoke-WinUtilSnapFlyout.ps1 +++ b/functions/private/Invoke-WinUtilSnapFlyout.ps1 @@ -14,7 +14,7 @@ function Invoke-WinUtilSnapFlyout { Write-Host "Disabling Snap Assist Flyout On startup" $value = 0 } - # taskkill.exe /F /IM "explorer.exe" + $Path = "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced" taskkill.exe /F /IM "explorer.exe" Set-ItemProperty -Path $Path -Name EnableSnapAssistFlyout -Value $value diff --git a/functions/public/Invoke-WPFToggle.ps1 b/functions/public/Invoke-WPFToggle.ps1 index d0b79da1..c4fbd105 100644 --- a/functions/public/Invoke-WPFToggle.ps1 +++ b/functions/public/Invoke-WPFToggle.ps1 @@ -15,23 +15,25 @@ function Invoke-WPFToggle { # 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 -DarkMoveEnabled $(Get-WinUtilToggleStatus WPFToggleDarkMode)} - "WPFToggleBingSearch" {Invoke-WinUtilBingSearch $(Get-WinUtilToggleStatus WPFToggleBingSearch)} - "WPFToggleNumLock" {Invoke-WinUtilNumLock $(Get-WinUtilToggleStatus WPFToggleNumLock)} - "WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $(Get-WinUtilToggleStatus WPFToggleVerboseLogon)} - "WPFToggleShowExt" {Invoke-WinUtilShowExt $(Get-WinUtilToggleStatus WPFToggleShowExt)} - "WPFToggleSnapWindow" {Invoke-WinUtilSnapWindow $(Get-WinUtilToggleStatus WPFToggleSnapWindow)} - "WPFToggleSnapFlyout" {Invoke-WinUtilSnapFlyout $(Get-WinUtilToggleStatus WPFToggleSnapFlyout)} - "WPFToggleSnapSuggestion" {Invoke-WinUtilSnapSuggestion $(Get-WinUtilToggleStatus WPFToggleSnapSuggestion)} - "WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $(Get-WinUtilToggleStatus WPFToggleMouseAcceleration)} - "WPFToggleStickyKeys" {Invoke-WinUtilStickyKeys $(Get-WinUtilToggleStatus WPFToggleStickyKeys)} - "WPFToggleTaskbarWidgets" {Invoke-WinUtilTaskbarWidgets $(Get-WinUtilToggleStatus WPFToggleTaskbarWidgets)} - "WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $(Get-WinUtilToggleStatus WPFToggleTaskbarSearch)} - "WPFToggleTaskView" {Invoke-WinUtilTaskView $(Get-WinUtilToggleStatus WPFToggleTaskView)} - "WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $(Get-WinUtilToggleStatus WPFToggleHiddenFiles)} - "WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $(Get-WinUtilToggleStatus WPFToggleTaskbarAlignment)} - "WPFToggleDetailedBSoD" {Invoke-WinUtilDetailedBSoD $(Get-WinUtilToggleStatus WPFToggleDetailedBSoD)} + "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} } }