diff --git a/config/tweaks.json b/config/tweaks.json index 63e48bd3..e27ab171 100644 --- a/config/tweaks.json +++ b/config/tweaks.json @@ -2708,12 +2708,28 @@ "Order": "a064_", "Type": "Toggle" }, + "WPFToggleSnapWindow": { + "Content": "Snap Window", + "Description": "If enabled you can align windows by dragging them. | Relogin Required", + "category": "Customize Preferences", + "panel": "2", + "Order": "a065_", + "Type": "Toggle" + }, "WPFToggleSnapFlyout": { "Content": "Snap Assist Flyout", "Description": "If enabled then Snap preview is disabled when maximize button is hovered.", "category": "Customize Preferences", "panel": "2", - "Order": "a065_", + "Order": "a066_", + "Type": "Toggle" + }, + "WPFToggleSnapSuggestion": { + "Content": "Snap Assist Suggestion", + "Description": "If enabled then you will get suggestions to snap other applications in the left over spaces.", + "category": "Customize Preferences", + "panel": "2", + "Order": "a067_", "Type": "Toggle" }, "WPFToggleMouseAcceleration": { @@ -2721,7 +2737,7 @@ "Description": "If Enabled then Cursor movement is affected by the speed of your physical mouse movements.", "category": "Customize Preferences", "panel": "2", - "Order": "a066_", + "Order": "a068_", "Type": "Toggle" }, "WPFToggleStickyKeys": { @@ -2729,7 +2745,7 @@ "Description": "If Enabled then Sticky Keys is activated - Sticky keys is an accessibility feature of some graphical user interfaces which assists users who have physical disabilities or help users reduce repetitive strain injury.", "category": "Customize Preferences", "panel": "2", - "Order": "a067_", + "Order": "a069_", "Type": "Toggle" }, "WPFOOSUbutton": { diff --git a/functions/private/Get-WinUtilToggleStatus.ps1 b/functions/private/Get-WinUtilToggleStatus.ps1 index 95160ef6..95499ef1 100644 --- a/functions/private/Get-WinUtilToggleStatus.ps1 +++ b/functions/private/Get-WinUtilToggleStatus.ps1 @@ -59,6 +59,15 @@ Function Get-WinUtilToggleStatus { return $false } } + if($ToggleSwitch -eq "WPFToggleSnapWindow"){ + $hidesnap = (Get-ItemProperty -path 'HKCU:\Control Panel\Desktop').WindowArrangementActive + if($hidesnap -eq 0){ + return $false + } + else{ + return $true + } + } if($ToggleSwitch -eq "WPFToggleSnapFlyout"){ $hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').EnableSnapAssistFlyout if($hidesnap -eq 0){ @@ -68,6 +77,15 @@ Function Get-WinUtilToggleStatus { return $true } } + if($ToggleSwitch -eq "WPFToggleSnapSuggestion"){ + $hidesnap = (Get-ItemProperty -path 'HKCU:\Software\Microsoft\Windows\CurrentVersion\Explorer\Advanced').SnapAssist + if($hidesnap -eq 0){ + return $false + } + else{ + return $true + } + } if($ToggleSwitch -eq "WPFToggleMouseAcceleration"){ $MouseSpeed = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseSpeed $MouseThreshold1 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold1 diff --git a/functions/private/Invoke-WinUtilSnapSuggestion.ps1 b/functions/private/Invoke-WinUtilSnapSuggestion.ps1 new file mode 100644 index 00000000..6fd35a14 --- /dev/null +++ b/functions/private/Invoke-WinUtilSnapSuggestion.ps1 @@ -0,0 +1,34 @@ +function Invoke-WinUtilSnapSuggestion { + <# + .SYNOPSIS + Disables/Enables Snap Assist Suggestions on startup + .PARAMETER Enabled + Indicates whether to enable or disable Snap Assist Suggestions on startup + #> + Param($Enabled) + Try{ + if ($Enabled -eq $false){ + Write-Host "Enabling Snap Assist Suggestion On startup" + $value = 1 + } + else { + Write-Host "Disabling Snap Assist Suggestion 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 SnapAssist -Value $value + Start-Process "explorer.exe" + } + 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 + } +} \ No newline at end of file diff --git a/functions/private/Invoke-WinUtilSnapWindow.ps1 b/functions/private/Invoke-WinUtilSnapWindow.ps1 new file mode 100644 index 00000000..a52950d4 --- /dev/null +++ b/functions/private/Invoke-WinUtilSnapWindow.ps1 @@ -0,0 +1,31 @@ +function Invoke-WinUtilSnapWindow { + <# + .SYNOPSIS + Disables/Enables Snapping Windows on startup + .PARAMETER Enabled + Indicates whether to enable or disable Snapping Windows on startup + #> + Param($Enabled) + Try{ + if ($Enabled -eq $false){ + Write-Host "Enabling Snap Windows On startup | Relogin Required" + $value = 1 + } + else { + Write-Host "Disabling Snap Windows On startup | Relogin Required" + $value = 0 + } + $Path = "HKCU:\Control Panel\Desktop" + Set-ItemProperty -Path $Path -Name WindowArrangementActive -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 + } +} \ No newline at end of file diff --git a/functions/public/Invoke-WPFToggle.ps1 b/functions/public/Invoke-WPFToggle.ps1 index fd8a82f4..a3c94875 100644 --- a/functions/public/Invoke-WPFToggle.ps1 +++ b/functions/public/Invoke-WPFToggle.ps1 @@ -22,7 +22,9 @@ function Invoke-WPFToggle { "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)}