Exemplo n.º 1
0
def result(cursorcomm):
	print int(cursorcomm)
	#define mapping to direction of movement
	mapping = [[0,0],[1,0],[-1,0],[0,-1],[0,1]]
	if int(cursorcomm) == 5:
		# User is blinking
		win32api.mouse_event(win32con.MOUSEEVENTF_LEFTDOWN, 0, 0)
		win32api.mouse_event(win32con.MOUSEEVENTF_LEFTUP,0, 0)
	else:
		cursorMovement.dp(mapping[int(cursorcomm)][0], mapping[int(cursorcomm)][1])
Exemplo n.º 2
0
import time
import cursorMovement
from ctypes import*

#  Convert integers into direction vectors
mapping = [[0,0],[0,0],[0,0],[1,0],[-1,0],[0,-1],[0,1]]

#  Generate file which sends cursor codes 3-6
#  for 60 frames each
myfile = open('input.txt', 'wb')
print 'Generating file...'
for i in [3,5,4,6]:
	for j in range(60):
		myfile.write(struct.pack("i", i))
myfile.close()
print 'done.'

#  Read in the file and slide the cursor accordingly
print 'Reading file...'
myfile = open('input.txt', 'rb')
while 1:
	data=myfile.read(4)
	if not data:
		break
	myint=struct.unpack('i', data)[0]
	cursorMovement.dp(mapping[myint][0], mapping[myint][1])
	
	print mapping[myint]
	time.sleep(0.0333333)
print 'done'
myfile.close()