Skip to content

Instantly share code, notes, and snippets.

@hylickipiotr
Last active November 1, 2024 11:42
Show Gist options
  • Select an option

  • Save hylickipiotr/98326e7ebe774871a24ce64b8c8e2963 to your computer and use it in GitHub Desktop.

Select an option

Save hylickipiotr/98326e7ebe774871a24ce64b8c8e2963 to your computer and use it in GitHub Desktop.
Set mouse speed in windows 10 on startup using powershell and windows scheduler. Speed is in range 1-20 (default: 10).
param([Int32]$Speed=10)
$MethodDefinition = @"
[DllImport("user32.dll", EntryPoint = "SystemParametersInfo")]
public static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
"@
$User32 = Add-Type -MemberDefinition $MethodDefinition -Name "User32Set" -Namespace Win32Functions -PassThru
$User32::SystemParametersInfo(0x0071,0,$Speed,0) | Out-Null
Set-ItemProperty -Path "HKCU:\Control Panel\Mouse" -Name MouseSensitivity -Value $Speed
<?xml version="1.0" encoding="UTF-16"?>
<Task version="1.4" xmlns="http://schemas.microsoft.com/windows/2004/02/mit/task">
<RegistrationInfo>
<URI>\Win10_SetMouseSpeed</URI>
</RegistrationInfo>
<Triggers>
<LogonTrigger>
<Enabled>true</Enabled>
</LogonTrigger>
</Triggers>
<Settings>
<MultipleInstancesPolicy>IgnoreNew</MultipleInstancesPolicy>
<AllowStartOnDemand>true</AllowStartOnDemand>
<Enabled>true</Enabled>
<UseUnifiedSchedulingEngine>true</UseUnifiedSchedulingEngine>
<ExecutionTimeLimit>PT0S</ExecutionTimeLimit>
</Settings>
<Actions>
<Exec>
<Command>powershell</Command>
<Arguments>-windowstyle hidden -file "%USERPROFILE%\Win10_SetMouseSpeed.ps1" -speed 15</Arguments>
</Exec>
</Actions>
</Task>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment