-
Notifications
You must be signed in to change notification settings - Fork 0
/
mouse.ps1
60 lines (48 loc) · 2.05 KB
/
mouse.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
$core = @"
using System.Runtime.InteropServices;
namespace System
{
public class MyWin32
{
public static bool SystemInfoByRef(uint uAction, uint uParam, ref uint lpvParam, uint fuWinIni)
{
return SystemParametersInfo(uAction, uParam, ref lpvParam, fuWinIni);
}
public static bool SystemInfoNonRef(uint uAction, uint uParam, uint lpvParam, uint fuWinIni)
{
return SystemParametersInfo(uAction, uParam, lpvParam, fuWinIni);
}
public static bool SystemInfoByArray(uint uAction, uint uParam, uint[] lpvParam, uint fuWinIni)
{
return SystemParametersInfo(uAction, uParam, lpvParam, fuWinIni);
}
[DllImport("User32.dll")]
private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, ref uint pvParam, uint fWinIni);
[DllImport("User32.dll")]
private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint pvParam, uint fWinIni);
[DllImport("User32.dll")]
private static extern bool SystemParametersInfo(uint uiAction, uint uiParam, uint[] pvParam, uint fWinIni);
}
}
"@
Add-Type -TypeDefinition $core
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
[System.UInt32[]] $threshold = @(0, 0, 0)
[System.MyWin32]::SystemInfoByArray(0x4,0,$threshold,2);
$speed = 0
[System.Boolean] $res = [System.MyWin32]::SystemInfoByRef(0x70, 0, [REF] $speed, 0)
if ($res -eq $true) {
Write-Host $speed –foregroundcolor “blue”
[System.Windows.Forms.MessageBox]::Show("Current speed = $speed")
switch ($speed)
{
6 {$speed = 10}
10 {$speed = 14}
14 {$speed = 6}
default {$speed = 6}
}
[System.MyWin32]::SystemInfoNonRef(0x71, 0, $speed, 0)
<# [Windows.Forms.MessageBox]::Show("Mouse speed updated to $speed", "Success!", [Windows.Forms.MessageBoxButtons]::OK, [Windows.Forms.MessageBoxIcon]::Information) #>
[System.Windows.Forms.MessageBox]::Show("Mouse speed updated to $speed", "Success!")
}
# Read-Host