-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmouse-jiggler.simple.ps1
54 lines (43 loc) · 1.22 KB
/
mouse-jiggler.simple.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
# Mouse Jiggler Script
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class MouseSimulator
{
[DllImport("user32.dll")]
public static extern bool SetCursorPos(int x, int y);
[DllImport("user32.dll")]
[return: MarshalAs(UnmanagedType.Bool)]
public static extern bool GetCursorPos(out POINT lpPoint);
[StructLayout(LayoutKind.Sequential)]
public struct POINT
{
public int X;
public int Y;
}
}
"@
# Set the sleep interval (in seconds)
$SleepInterval = 10
$movePixels = 10
function Move-MouseBack-And-Forth {
$point = New-Object MouseSimulator+POINT
[MouseSimulator]::GetCursorPos([ref]$point)
# Move right
[MouseSimulator]::SetCursorPos($point.X + $movePixels, $point.Y)
Start-Sleep -Milliseconds 100
# Move back
[MouseSimulator]::SetCursorPos($point.X, $point.Y)
Write-Host "Mouse moved at $(Get-Date -Format 'HH:mm:ss')"
}
Write-Host "Mouse jiggler started. Press Ctrl+C to stop."
Write-Host "Moving mouse every $SleepInterval seconds..."
try {
while ($true) {
Move-MouseBack-And-Forth
Start-Sleep -Seconds $SleepInterval
}
}
catch {
Write-Host "`nMouse jiggler stopped."
}