From 904e0ad468a645d09db0c6d369d472707ca217ee Mon Sep 17 00:00:00 2001 From: "Mr.k" Date: Mon, 15 Jul 2024 04:47:40 +0300 Subject: [PATCH 1/3] Add New Windows 11 Specific Toggle - The 'Taskbar Alignment' Toggle (#2347) --- config/tweaks.json | 8 +++++ functions/private/Get-WinUtilToggleStatus.ps1 | 17 +++++++--- .../Invoke-WinUtilTaskbarAlignment.ps1 | 34 +++++++++++++++++++ functions/public/Invoke-WPFToggle.ps1 | 1 + 4 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 functions/private/Invoke-WinUtilTaskbarAlignment.ps1 diff --git a/config/tweaks.json b/config/tweaks.json index ea19f27c..88919728 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -3123,6 +3123,14 @@ "Order": "a204_", "Type": "Toggle" }, + "WPFToggleTaskbarAlignment": { + "Content": "Switch Taskbar Items between Center & Left", + "Description": "[Windows 11] If Enabled then the Taskbar Items will be shown on the Center, otherwise the Taskbar Items will be shown on the Left.", + "category": "Customize Preferences", + "panel": "2", + "Order": "a204_", + "Type": "Toggle" + }, "WPFOOSUbutton": { "Content": "Run OO Shutup 10", "category": "z__Advanced Tweaks - CAUTION", diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index c7f0a8a9..76245f9b 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -138,11 +138,20 @@ Function Get-WinUtilToggleStatus { if ($ToggleSwitch -eq "WPFToggleTaskbarWidgets") { $TaskbarWidgets = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskBarDa - if($TaskbarWidgets -eq 0) { + if($TaskbarWidgets -eq 0) { return $false - } - else{ + } + else{ return $true - } + } + } + if ($ToggleSwitch -eq "WPFToggleTaskbarAlignment") { + $TaskbarAlignment = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskbarAl + if($TaskbarAlignment -eq 0) { + return $false + } + else{ + return $true + } } } diff --git a/functions/private/Invoke-WinUtilTaskbarAlignment.ps1 b/functions/private/Invoke-WinUtilTaskbarAlignment.ps1 new file mode 100644 index 00000000..0c5e0dfa --- /dev/null +++ b/functions/private/Invoke-WinUtilTaskbarAlignment.ps1 @@ -0,0 +1,34 @@ +function Invoke-WinUtilTaskbarAlignment { + <# + + .SYNOPSIS + Switches between Center & Left Taskbar Alignment + + .PARAMETER Enabled + Indicates whether to make Taskbar Alignment Center or Left + + #> + Param($Enabled) + Try{ + if ($Enabled -eq $false){ + Write-Host "Making Taskbar Alignment to the Center" + $value = 1 + } + else { + Write-Host "Making Taskbar Alignment to the Left" + $value = 0 + } + $Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" + Set-ItemProperty -Path $Path -Name "TaskbarAl" -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 + } +} diff --git a/functions/public/Invoke-WPFToggle.ps1 b/functions/public/Invoke-WPFToggle.ps1 index 4bb4caa4..539878c7 100644 --- a/functions/public/Invoke-WPFToggle.ps1 +++ b/functions/public/Invoke-WPFToggle.ps1 @@ -31,5 +31,6 @@ function Invoke-WPFToggle { "WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $(Get-WinUtilToggleStatus WPFToggleTaskbarSearch)} "WPFToggleTaskView" {Invoke-WinUtilTaskView $(Get-WinUtilToggleStatus WPFToggleTaskView)} "WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $(Get-WinUtilToggleStatus WPFToggleHiddenFiles)} + "WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $(Get-WinUtilToggleStatus WPFToggleTaskbarAlignment)} } } From c9934a53b09d39cfe4998e44d48a3b4b74d0ccfa Mon Sep 17 00:00:00 2001 From: ChrisTitusTech Date: Mon, 15 Jul 2024 01:48:28 +0000 Subject: [PATCH 2/3] Compile Winutil --- winutil.ps1 | 64 +++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 60 insertions(+), 4 deletions(-) diff --git a/winutil.ps1 b/winutil.ps1 index 4dcf6dee..1b0777a0 100644 --- a/winutil.ps1 +++ b/winutil.ps1 @@ -728,12 +728,21 @@ Function Get-WinUtilToggleStatus { if ($ToggleSwitch -eq "WPFToggleTaskbarWidgets") { $TaskbarWidgets = (Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskBarDa - if($TaskbarWidgets -eq 0) { + if($TaskbarWidgets -eq 0) { return $false - } - else{ + } + else{ return $true - } + } + } + if ($ToggleSwitch -eq "WPFToggleTaskbarAlignment") { + $TaskbarAlignment = (Get-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced").TaskbarAl + if($TaskbarAlignment -eq 0) { + return $false + } + else{ + return $true + } } } function Get-WinUtilVariables { @@ -2403,6 +2412,40 @@ Function Invoke-WinUtilStickyKeys { Write-Warning $psitem.Exception.StackTrace } } +function Invoke-WinUtilTaskbarAlignment { + <# + + .SYNOPSIS + Switches between Center & Left Taskbar Alignment + + .PARAMETER Enabled + Indicates whether to make Taskbar Alignment Center or Left + + #> + Param($Enabled) + Try{ + if ($Enabled -eq $false){ + Write-Host "Making Taskbar Alignment to the Center" + $value = 1 + } + else { + Write-Host "Making Taskbar Alignment to the Left" + $value = 0 + } + $Path = "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced" + Set-ItemProperty -Path $Path -Name "TaskbarAl" -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-WinUtilTaskbarSearch { <# @@ -5106,6 +5149,7 @@ function Invoke-WPFToggle { "WPFToggleTaskbarSearch" {Invoke-WinUtilTaskbarSearch $(Get-WinUtilToggleStatus WPFToggleTaskbarSearch)} "WPFToggleTaskView" {Invoke-WinUtilTaskView $(Get-WinUtilToggleStatus WPFToggleTaskView)} "WPFToggleHiddenFiles" {Invoke-WinUtilHiddenFiles $(Get-WinUtilToggleStatus WPFToggleHiddenFiles)} + "WPFToggleTaskbarAlignment" {Invoke-WinUtilTaskbarAlignment $(Get-WinUtilToggleStatus WPFToggleTaskbarAlignment)} } } function Invoke-WPFTweakPS7{ @@ -12275,6 +12319,14 @@ $sync.configs.tweaks = '{ "Order": "a204_", "Type": "Toggle" }, + "WPFToggleTaskbarAlignment": { + "Content": "Switch Taskbar Items between Center & Left", + "Description": "[Windows 11] If Enabled then the Taskbar Items will be shown on the Center, otherwise the Taskbar Items will be shown on the Left.", + "category": "Customize Preferences", + "panel": "2", + "Order": "a204_", + "Type": "Toggle" + }, "WPFOOSUbutton": { "Content": "Run OO Shutup 10", "category": "z__Advanced Tweaks - CAUTION", @@ -14727,6 +14779,10 @@ $inputXML = '