aekrohn

First commit;

Showing 1 changed file with 45 additions and 0 deletions
import sys
import time
import logging
from Quartz.CoreGraphics import CGEventCreateMouseEvent
from Quartz.CoreGraphics import CGEventPost
from Quartz.CoreGraphics import kCGEventMouseMoved
from Quartz.CoreGraphics import kCGEventLeftMouseDown
from Quartz.CoreGraphics import kCGEventLeftMouseUp
from Quartz.CoreGraphics import kCGMouseButtonLeft
from Quartz.CoreGraphics import kCGHIDEventTap
def mouseEvent(type, posx, posy):
event = CGEventCreateMouseEvent(None, type, (posx, posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, event)
def mouseMove(posx, posy):
mouseEvent(kCGEventLeftMouseDown, posx, posy)
mouseEvent(kCGEventLeftMouseUp, posx, posy)
def mouseClick(posx, posy):
mouseEvent(kCGEventMouseMoved, posx, poxy)
mouseEvent(kCGEventLeftMouseDown, posx, posy)
mouseEvent(kCGEventLeftMouseUp, posx, posy)
if __name__ == '__main__':
logging.basicConfig(level=logging.DEBUG, format='%(asctime)s %(message)s')
# Initial mouse placement
logging.info('Initializing mouse mover, setting 100x100')
mouseMove(100,100)
while True:
logging.info('Jiggling mouse')
for _ in range(10):
for i in range(100):
mouseMove(101+i, 101+i)
for i in range(100):
mouseMove(200-i, 200-i)
mouseMove(100,100)
logging.info('Sleeping 60 seconds')
time.sleep(60)
... ...