Created
September 13, 2024 11:07
-
-
Save mrrootsec/ad9f869b0dcbdf9e1f15c3bba9325098 to your computer and use it in GitHub Desktop.
Prevent PC from sleeping - Win 11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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