Created
November 8, 2013 23:59
-
-
Save antonva/7379568 to your computer and use it in GitHub Desktop.
Músarkódi í python. (tharf bruteforce thar sem shittid er volatile(
This file contains 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
import sys | |
import serial | |
import time | |
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 kCGEventRightMouseDown | |
from Quartz.CoreGraphics import kCGEventRightMouseUp | |
from Quartz.CoreGraphics import kCGMouseButtonLeft | |
from Quartz.CoreGraphics import kCGMouseButtonRight | |
from Quartz.CoreGraphics import kCGHIDEventTap | |
#display setup because we're lazy | |
screenx = 1440 | |
screeny = 800 | |
# Serial setup | |
print "trying to connect to serial.." | |
ser = serial.Serial('/dev/tty.usbmodemfa131',9600) | |
def mouseEvent(type, posx, posy): | |
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft) | |
CGEventPost(kCGHIDEventTap, theEvent) | |
def mousemove(posx,posy): | |
mouseEvent(kCGEventMouseMoved, posx,posy); | |
def lmouseclick(posx,posy): | |
mouseEvent(kCGEventLeftMouseDown, posx,posy); | |
mouseEvent(kCGEventLeftMouseUp, posx,posy); | |
def rmouseclick(posx,posy): | |
mouseEvent(kCGEventRightMouseDown, posx,posy); | |
mouseEvent(kCGEventRightMouseUp, posx,posy); | |
while True: | |
data = ser.readline() | |
splitdata = data.split(',') | |
xcorrect = int(splitdata[1]) | |
x = xcorrect * 5.625 | |
splitdata = data.split(',') | |
ycorrect = int(splitdata[2]) | |
y = ycorrect * 3.25 | |
splitdata = data.split(',') | |
if int(splitdata[3]) == 0: | |
lmouseclick(x,y) | |
splitdata = data.split(',') | |
if int(splitdata[4]) == 0: | |
rmouseclick(x,y) | |
mousemove(x,y) | |
#print "x: " + str(x) + " y: " + str(y); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment