Skip to content

Instantly share code, notes, and snippets.

@mohamedmansour
Created February 29, 2012 00:46
Show Gist options
  • Save mohamedmansour/1936613 to your computer and use it in GitHub Desktop.
Save mohamedmansour/1936613 to your computer and use it in GitHub Desktop.
Auto Move your mouse to keep Google+ Hangout alive.
#!/usr/bin/python
import win32api, win32con
import threading
class AutoMouseMove(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.event = threading.Event()
self.state = False
self.first_point = (100, 5)
self.second_point = (win32api.GetSystemMetrics(0) / 2, win32api.GetSystemMetrics(1) / 2)
def run(self):
while True:
self.state = not self.state
self.event.wait(3)
self.execute()
def execute(self):
move_to_point = self.first_point
if self.state:
move_to_point = self.second_point
win32api.SetCursorPos(move_to_point)
win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN | win32con.MOUSEEVENTF_LEFTUP,
move_to_point[0], move_to_point[1], 0, 0)
auto = AutoMouseMove()
auto.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment