Skip to content

Commit

Permalink
convert mouse acceleration checkboxs into togglebutton
Browse files Browse the repository at this point in the history
  • Loading branch information
padsalatushal committed Nov 7, 2023
1 parent 9fd3a9d commit 1953289
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 128 deletions.
61 changes: 0 additions & 61 deletions config/tweaks.json
Original file line number Diff line number Diff line change
Expand Up @@ -1909,17 +1909,6 @@
}
]
},
"WPFMiscTweaksExt": {
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "HideFileExt",
"Type": "DWord",
"Value": "0",
"OriginalValue": "1"
}
]
},
"WPFMiscTweaksUTC": {
"registry": [
{
Expand Down Expand Up @@ -2305,56 +2294,6 @@
}
]
},
"WPFMiscTweaksDisableMouseAcceleration": {
"registry": [
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "1",
"Name": "MouseSpeed",
"Value": "0",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "6",
"Name": "MouseThreshold1",
"Value": "0",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "10",
"Name": "MouseThreshold2",
"Value": "0",
"Type": "String"
}
]
},
"WPFMiscTweaksEnableMouseAcceleration": {
"registry": [
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "1",
"Name": "MouseSpeed",
"Value": "1",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "6",
"Name": "MouseThreshold1",
"Value": "6",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "10",
"Name": "MouseThreshold2",
"Value": "10",
"Type": "String"
}
]
},
"WPFEssTweaksDeleteTempFiles": {
"InvokeScript": [
"Get-ChildItem -Path \"C:\\Windows\\Temp\" *.* -Recurse | Remove-Item -Force -Recurse
Expand Down
12 changes: 12 additions & 0 deletions functions/private/Get-WinUtilToggleStatus.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,16 @@ Function Get-WinUtilToggleStatus {
return $false
}
}
if($ToggleSwitch -eq "WPFToggleMouseAcceleration"){
$MouseSpeed = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseSpeed
$MouseThreshold1 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold1
$MouseThreshold2 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold2

if($MouseSpeed -eq 1 -and $MouseThreshold1 -eq 6 -and $MouseThreshold2 -eq 10){
return $true
}
else{
return $false
}
}
}
42 changes: 42 additions & 0 deletions functions/private/Invoke-WinUtilMouseAcceleration.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
Function Invoke-WinUtilMouseAcceleration {
<#
.SYNOPSIS
Enables/Disables Mouse Acceleration
.PARAMETER DarkMoveEnabled
Indicates the current Mouse Acceleration State
#>
Param($MouseAccelerationEnabled)
Try{
if ($MouseAccelerationEnabled -eq $false){
Write-Host "Enabling Mouse Acceleration"
$MouseSpeed = 1
$MouseThreshold1 = 6
$MouseThreshold2 = 10
}
else {
Write-Host "Disabling Mouse Acceleration"
$MouseSpeed = 0
$MouseThreshold1 = 0
$MouseThreshold2 = 0

}

$Path = "HKCU:\Control Panel\Mouse"
Set-ItemProperty -Path $Path -Name MouseSpeed -Value $MouseSpeed
Set-ItemProperty -Path $Path -Name MouseThreshold1 -Value $MouseThreshold1
Set-ItemProperty -Path $Path -Name MouseThreshold2 -Value $MouseThreshold2
}
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
}
}
1 change: 1 addition & 0 deletions functions/public/Invoke-WPFToggle.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@ function Invoke-WPFToggle {
"WPFToggleNumLock" {Invoke-WinUtilNumLock $(Get-WinUtilToggleStatus WPFToggleNumLock)}
"WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $(Get-WinUtilToggleStatus WPFToggleVerboseLogon)}
"WPFToggleShowExt" {Invoke-WinUtilShowExt $(Get-WinUtilToggleStatus WPFToggleShowExt)}
"WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $(Get-WinUtilToggleStatus WPFToggleMouseAcceleration)}
}
}
126 changes: 62 additions & 64 deletions winutil.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,18 @@ Function Get-WinUtilToggleStatus {
return $false
}
}
if($ToggleSwitch -eq "WPFToggleMouseAcceleration"){
$MouseSpeed = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseSpeed
$MouseThreshold1 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold1
$MouseThreshold2 = (Get-ItemProperty -path 'HKCU:\Control Panel\Mouse').MouseThreshold2

if($MouseSpeed -eq 1 -and $MouseThreshold1 -eq 6 -and $MouseThreshold2 -eq 10){
return $true
}
else{
return $false
}
}
}
function Get-WinUtilVariables {

Expand Down Expand Up @@ -599,6 +611,48 @@ function Invoke-WinUtilFeatureInstall {
}
}
}
Function Invoke-WinUtilMouseAcceleration {
<#
.SYNOPSIS
Enables/Disables Mouse Acceleration
.PARAMETER DarkMoveEnabled
Indicates the current Mouse Acceleration State
#>
Param($MouseAccelerationEnabled)
Try{
if ($MouseAccelerationEnabled -eq $false){
Write-Host "Enabling Mouse Acceleration"
$MouseSpeed = 1
$MouseThreshold1 = 6
$MouseThreshold2 = 10
}
else {
Write-Host "Disabling Mouse Acceleration"
$MouseSpeed = 0
$MouseThreshold1 = 0
$MouseThreshold2 = 0

}

$Path = "HKCU:\Control Panel\Mouse"
Set-ItemProperty -Path $Path -Name MouseSpeed -Value $MouseSpeed
Set-ItemProperty -Path $Path -Name MouseThreshold1 -Value $MouseThreshold1
Set-ItemProperty -Path $Path -Name MouseThreshold2 -Value $MouseThreshold2
}
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-WinUtilNumLock {
<#
.SYNOPSIS
Expand Down Expand Up @@ -1826,6 +1880,7 @@ function Invoke-WPFToggle {
"WPFToggleNumLock" {Invoke-WinUtilNumLock $(Get-WinUtilToggleStatus WPFToggleNumLock)}
"WPFToggleVerboseLogon" {Invoke-WinUtilVerboseLogon $(Get-WinUtilToggleStatus WPFToggleVerboseLogon)}
"WPFToggleShowExt" {Invoke-WinUtilShowExt $(Get-WinUtilToggleStatus WPFToggleShowExt)}
"WPFToggleMouseAcceleration" {Invoke-WinUtilMouseAcceleration $(Get-WinUtilToggleStatus WPFToggleMouseAcceleration)}
}
}
function Invoke-WPFtweaksbutton {
Expand Down Expand Up @@ -2934,8 +2989,7 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
<CheckBox Name="WPFEssTweaksRemoveEdge" Content="Remove Microsoft Edge - NOT RECOMMENDED" Margin="5,0" ToolTip="Removes MS Edge when it gets reinstalled by updates."/>
<CheckBox Name="WPFEssTweaksRemoveOnedrive" Content="Remove OneDrive" Margin="5,0" ToolTip="Copies OneDrive files to Default Home Folders and Uninstalls it."/>
<CheckBox Name="WPFMiscTweaksRightClickMenu" Content="Set Classic Right-Click Menu " Margin="5,0" ToolTip="Great Windows 11 tweak to bring back good context menus when right clicking things in explorer."/>
<CheckBox Name="WPFMiscTweaksDisableMouseAcceleration" Content="Disable Mouse Acceleration" Margin="5,0" ToolTip="Disables Mouse Acceleration."/>
<CheckBox Name="WPFMiscTweaksEnableMouseAcceleration" Content="Enable Mouse Acceleration" Margin="5,0" ToolTip="Enables Mouse Acceleration."/>
<CheckBox Name="WPFMiscTweaksDisableipsix" Content="Disable IPv6" Margin="5,0" ToolTip="Disables IPv6."/>
<CheckBox Name="WPFMiscTweaksEnableipsix" Content="Enable IPv6" Margin="5,0" ToolTip="Enables IPv6."/>
Expand Down Expand Up @@ -2985,7 +3039,12 @@ $inputXML = '<Window x:Class="WinUtility.MainWindow"
<Label Content="Show File Extentions" />
<CheckBox Name="WPFToggleShowExt" Style="{StaticResource ColorfulToggleSwitchStyle}" Margin="2.5,0"/>
</StackPanel>
<!-- <CheckBox Name="WPFMiscTweaksDisableMouseAcceleration" Content="Disable Mouse Acceleration" Margin="5,0" ToolTip="Disables Mouse Acceleration."/>
<CheckBox Name="WPFMiscTweaksEnableMouseAcceleration" Content="Enable Mouse Acceleration" Margin="5,0" ToolTip="Enables Mouse Acceleration."/> -->
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Mouse Acceleration" />
<CheckBox Name="WPFToggleMouseAcceleration" Style="{StaticResource ColorfulToggleSwitchStyle}" Margin="2.5,0"/>
</StackPanel>
</StackPanel> <!-- End of Customize Preferences Section -->
Expand Down Expand Up @@ -5780,17 +5839,6 @@ $sync.configs.tweaks = '{
}
]
},
"WPFMiscTweaksExt": {
"registry": [
{
"Path": "HKCU:\\Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced",
"Name": "HideFileExt",
"Type": "DWord",
"Value": "0",
"OriginalValue": "1"
}
]
},
"WPFMiscTweaksUTC": {
"registry": [
{
Expand Down Expand Up @@ -6176,56 +6224,6 @@ $sync.configs.tweaks = '{
}
]
},
"WPFMiscTweaksDisableMouseAcceleration": {
"registry": [
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "1",
"Name": "MouseSpeed",
"Value": "0",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "6",
"Name": "MouseThreshold1",
"Value": "0",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "10",
"Name": "MouseThreshold2",
"Value": "0",
"Type": "String"
}
]
},
"WPFMiscTweaksEnableMouseAcceleration": {
"registry": [
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "1",
"Name": "MouseSpeed",
"Value": "1",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "6",
"Name": "MouseThreshold1",
"Value": "6",
"Type": "String"
},
{
"Path": "HKCU:\\Control Panel\\Mouse",
"OriginalValue": "10",
"Name": "MouseThreshold2",
"Value": "10",
"Type": "String"
}
]
},
"WPFEssTweaksDeleteTempFiles": {
"InvokeScript": [
"Get-ChildItem -Path \"C:\\Windows\\Temp\" *.* -Recurse | Remove-Item -Force -Recurse
Expand Down
10 changes: 7 additions & 3 deletions xaml/inputXML.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -591,8 +591,7 @@
<CheckBox Name="WPFEssTweaksRemoveEdge" Content="Remove Microsoft Edge - NOT RECOMMENDED" Margin="5,0" ToolTip="Removes MS Edge when it gets reinstalled by updates."/>
<CheckBox Name="WPFEssTweaksRemoveOnedrive" Content="Remove OneDrive" Margin="5,0" ToolTip="Copies OneDrive files to Default Home Folders and Uninstalls it."/>
<CheckBox Name="WPFMiscTweaksRightClickMenu" Content="Set Classic Right-Click Menu " Margin="5,0" ToolTip="Great Windows 11 tweak to bring back good context menus when right clicking things in explorer."/>
<CheckBox Name="WPFMiscTweaksDisableMouseAcceleration" Content="Disable Mouse Acceleration" Margin="5,0" ToolTip="Disables Mouse Acceleration."/>
<CheckBox Name="WPFMiscTweaksEnableMouseAcceleration" Content="Enable Mouse Acceleration" Margin="5,0" ToolTip="Enables Mouse Acceleration."/>


<CheckBox Name="WPFMiscTweaksDisableipsix" Content="Disable IPv6" Margin="5,0" ToolTip="Disables IPv6."/>
<CheckBox Name="WPFMiscTweaksEnableipsix" Content="Enable IPv6" Margin="5,0" ToolTip="Enables IPv6."/>
Expand Down Expand Up @@ -642,7 +641,12 @@
<Label Content="Show File Extentions" />
<CheckBox Name="WPFToggleShowExt" Style="{StaticResource ColorfulToggleSwitchStyle}" Margin="2.5,0"/>
</StackPanel>

<!-- <CheckBox Name="WPFMiscTweaksDisableMouseAcceleration" Content="Disable Mouse Acceleration" Margin="5,0" ToolTip="Disables Mouse Acceleration."/>
<CheckBox Name="WPFMiscTweaksEnableMouseAcceleration" Content="Enable Mouse Acceleration" Margin="5,0" ToolTip="Enables Mouse Acceleration."/> -->
<StackPanel Orientation="Horizontal" Margin="0,10,0,0">
<Label Content="Mouse Acceleration" />
<CheckBox Name="WPFToggleMouseAcceleration" Style="{StaticResource ColorfulToggleSwitchStyle}" Margin="2.5,0"/>
</StackPanel>

</StackPanel> <!-- End of Customize Preferences Section -->

Expand Down

0 comments on commit 1953289

Please sign in to comment.