Created
October 14, 2016 16:40
-
-
Save tbnorth/492e31ef24cc3c367ac141b4faa2a8cd to your computer and use it in GitHub Desktop.
Python mouse mover for screen saver suppression
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
""" | |
Using mouse events rather than just moving the cursor is important | |
""" | |
import sys | |
import time | |
import win32api | |
import win32con | |
last = -1 | |
while True: | |
for i in range(4): | |
last *= -1 | |
x, y = win32api.GetCursorPos() | |
x += 5*last | |
y += 5*last | |
nx = x*65535/win32api.GetSystemMetrics(0) | |
ny = y*65535/win32api.GetSystemMetrics(1) | |
win32api.mouse_event( | |
win32con.MOUSEEVENTF_ABSOLUTE | | |
win32con.MOUSEEVENTF_MOVE, | |
nx, ny | |
) | |
time.sleep(0.1) | |
print time.asctime(), x, y | |
time.sleep(30) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment