diff --git a/EnhanceWindows.ps1 b/EnhanceWindows.ps1 index 2b4081d..831d4b4 100644 --- a/EnhanceWindows.ps1 +++ b/EnhanceWindows.ps1 @@ -32,11 +32,68 @@ write-host " " } +function Test-RegistryValue { + param ( + [Parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [string]$Path, + + [Parameter(Mandatory=$true)] + [ValidateNotNullOrEmpty()] + [string]$Value + ) + + try { + $registryValue = Get-ItemProperty -Path $Path -ErrorAction Stop + if ($registryValue.PSObject.Properties.Name -contains $Value) { + return $true + } else { + return $false + } + } + catch { + return $false + } +} +function PreWin10 { + if (-Not (Test-RegistryValue -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People' -Value 'PeopleBand')) { + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Value 0 + } + if (-Not (Test-RegistryValue -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace' -Value 'PenWorkspaceButtonDesiredVisibility')) { + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace" -Name "PenWorkspaceButtonDesiredVisibility" -Value 0 + } + if (-Not (Test-RegistryValue -Path 'HKCU:\SOFTWARE\Microsoft\TabletTip\1.7' -Value 'TipbandDesiredVisibility')) { + Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\TabletTip\1.7" -Name "TipbandDesiredVisibility" -Value 0 + } +} + +$windowsVersion = [System.Environment]::OSVersion.Version.Major + +if ($windowsVersion -eq 10) { + PreWin10 +} elseif ($windowsVersion -eq 11) { + PreWin11 +} +function PreWin11 { + # if (-Not (Test-RegistryValue -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People' -Value 'PeopleBand')) { + # Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Value 0 + # } + # if (-Not (Test-RegistryValue -Path 'HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace' -Value 'PenWorkspaceButtonDesiredVisibility')) { + # Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace" -Name "PenWorkspaceButtonDesiredVisibility" -Value 0 + # } + # if (-Not (Test-RegistryValue -Path 'HKCU:\SOFTWARE\Microsoft\TabletTip\1.7' -Value 'TipbandDesiredVisibility')) { + # Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\TabletTip\1.7" -Name "TipbandDesiredVisibility" -Value 0 + # } +write-host "=------------------------------=" +write-host " Windows 11 is still in WIP " +write-host "=------------------------------=" +} + @@ -440,40 +497,24 @@ if($value8.ShowCortanaButton -eq 0) $WPFUnpin_People.Add_Checked({RemPeople}) $WPFUnpin_People.Add_UnChecked({RemPeople}) $value9 = Get-ItemProperty -path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -if ($value9) { - if ($value9.PeopleBand -eq 0) { - $WPFUnpin_People.IsChecked = $true - } -} -else { - # If the registry value doesn't exist, create it with a value of 0 - Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\Advanced\People" -Name "PeopleBand" -Value 0 +if ($value9.PeopleBand -eq 0) { + $WPFUnpin_People.IsChecked = $true } $WPFUnpin_Ink_Workspace.Add_Checked({RemInkWS}) $WPFUnpin_Ink_Workspace.Add_UnChecked({RemInkWS}) $value10 = Get-ItemProperty -path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace\" -Name "PenWorkspaceButtonDesiredVisibility" -if ($value10) { - if ($value10.PenWorkspaceButtonDesiredVisibility -eq 0) { - $WPFUnpin_Ink_Workspace.IsChecked = $true - } -} -else { - # If the registry value doesn't exist, create it with a value of 0 - Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\PenWorkspace" -Name "PenWorkspaceButtonDesiredVisibility" -Value 0 +if ($value10.PenWorkspaceButtonDesiredVisibility -eq 0) { + $WPFUnpin_Ink_Workspace.IsChecked = $true } + $WPFUnpin_Touch_Keyboard.Add_Checked({RemTouchKey}) $WPFUnpin_Touch_Keyboard.Add_UnChecked({RemTouchKey}) $value11 = Get-ItemProperty -path "HKCU:\SOFTWARE\Microsoft\TabletTip\1.7" -Name "TipbandDesiredVisibility" -if ($value11) { - if ($value11.TipbandDesiredVisibility -eq 0) { - $WPFUnpin_Touch_Keyboard.IsChecked = $true - } -} -else { - # If the registry value doesn't exist, create it with a value of 0 - Set-ItemProperty -Path "HKCU:\SOFTWARE\Microsoft\TabletTip\1.7" -Name "TipbandDesiredVisibility" -Value 0 +if($value11.TipbandDesiredVisibility -eq 0) +{ + $WPFUnpin_Touch_Keyboard.IsChecked = $true } @@ -753,8 +794,7 @@ $WPFWin10RC.Visibility = "Hidden" - -$windowsVersion = [System.Environment]::OSVersion.Version.Major +OlaYZen if ($windowsVersion -eq 10) { Win10 diff --git a/MainWindow.xaml b/MainWindow.xaml index 0813402..e733191 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -64,7 +64,7 @@