I'm building mouse movement filter program for Windows and Mac OS X. In Windows I use ctypes.windll.user32.getCursorPos(pointer) and ctypes.windll.user32.setCursorPos(x,y) to get and set the cursor position but I do not know what the library and functions are called in Mac OS X (I'm a complete noob when it comes to Mac :) )
To explain better (I hope) here is the windows code for a test program that forces the mouse to use a static speed:
Expand|Select|Wrap|Line Numbers
- import ctypes
- class POINT(ctypes.Structure):
- _fields_ = [("x", ctypes.c_long),
- ("y", ctypes.c_long)]
- point = POINT()
- pi = ctypes.pointer(point)
- ctypes.windll.user32.GetCursorPos(pi)
- newMousePosX = point.x
- newMousePosY = point.y
- mouseSpeed = 5
- while True:
- ctypes.windll.user32.GetCursorPos(pi)
- if(newMousePosX != point.x or newMousePosY != point.y):
- if(point.x > newMousePosX):
- newMousePosX += mouseSpeed
- elif(point.x < newMousePosX):
- newMousePosX -= mouseSpeed
- if(point.y > newMousePosY):
- newMousePosY += mouseSpeed
- elif(point.y < newMousePosY):
- newMousePosY -= mouseSpeed
- ctypes.windll.user32.SetCursorPos(newMousePosX, newMousePosY)
Regards
Malen