Skip to content

Instantly share code, notes, and snippets.

@mrrootsec
Created September 13, 2024 11:07
Show Gist options
  • Save mrrootsec/ad9f869b0dcbdf9e1f15c3bba9325098 to your computer and use it in GitHub Desktop.
Save mrrootsec/ad9f869b0dcbdf9e1f15c3bba9325098 to your computer and use it in GitHub Desktop.
Prevent PC from sleeping - Win 11
Add-Type -TypeDefinition @"
using System;
using System.Runtime.InteropServices;
public class MouseSimulator {
[DllImport("user32.dll", SetLastError = true)]
private static extern void mouse_event(uint dwFlags, int dx, int dy, uint dwData, int dwExtraInfo);
private const uint MOUSEEVENTF_MOVE = 0x0001;
public static void SimulateMouseMove() {
mouse_event (MOUSEEVENTF_MOVE, 0, 0, 0, 0);
}
}
"@
while ($true) {
[MouseSimulator]:: SimulateMouseMove()
Start-Sleep -Seconds 200
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment