Skip to content

Instantly share code, notes, and snippets.

@Kyu
Created October 7, 2024 20:36
Show Gist options
  • Save Kyu/609bb874efc8b29e6cdb20861b4c920f to your computer and use it in GitHub Desktop.
Save Kyu/609bb874efc8b29e6cdb20861b4c920f to your computer and use it in GitHub Desktop.
$code = '[DllImport("user32.dll")] public static extern bool GetAsyncKeyState(int button); public static bool IsMouseClicked() { return GetAsyncKeyState((int) 0x01); }'
Add-Type -name mouse -member $code -namespace prank;
# [prank.mouse]::IsMouseClicked()
# [Windows.Forms.Cursor]::Position = "2500, 1000"
$originalPOS = [System.Windows.Forms.Cursor]::Position
$voice = New-Object -ComObject Sapi.spvoice
$voice.rate = 0
while (1) {
if ([prank.mouse]::IsMouseClicked()){
echo "Move! ${n}"
$n = $n + 1
    Start-Sleep -Seconds 0.1
    $newPOS = [System.Windows.Forms.Cursor]::Position
    [Windows.Forms.Cursor]::Position = $originalPOS
$originalPOS = $newPOS
    if (n % 7 -eq 0) { $voice.speak("Pranked") }
}
else {
Start-Sleep -Seconds 0.01
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment