-
Notifications
You must be signed in to change notification settings - Fork 6
/
setMouseSpeed.ps1
30 lines (23 loc) · 901 Bytes
/
setMouseSpeed.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
param (
[validateRange(1,20)]
[int] $newSpeed
)
set-strictMode -version latest
$winApi = add-type -name user32 -namespace tq84 -passThru -memberDefinition '
[DllImport("user32.dll")]
public static extern bool SystemParametersInfo(
uint uiAction,
uint uiParam ,
uint pvParam ,
uint fWinIni
);
'
$SPI_SETMOUSESPEED = 0x0071
"MouseSensitivity before WinAPI call: $((get-itemProperty 'hkcu:\Control Panel\Mouse').MouseSensitivity)"
$null = $winApi::SystemParametersInfo($SPI_SETMOUSESPEED, 0, $newSpeed, 0)
#
# Calling SystemParametersInfo() does not permanently store the modification
# of the mouse speed. It needs to be changed in the registry as well
#
"MouseSensitivity after WinAPI call: $((get-itemProperty 'hkcu:\Control Panel\Mouse').MouseSensitivity)"
set-itemProperty 'hkcu:\Control Panel\Mouse' -name MouseSensitivity -value $newSpeed