469,616 Members | 1,696 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,616 developers. It's quick & easy.

Accesing mouse library functions with ctypes in Mac OS X

1
Hi all!


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
  1. import ctypes
  2.  
  3. class POINT(ctypes.Structure):
  4.     _fields_ = [("x", ctypes.c_long),
  5.                 ("y", ctypes.c_long)]
  6.  
  7. point = POINT()
  8.  
  9. pi = ctypes.pointer(point) 
  10. ctypes.windll.user32.GetCursorPos(pi)
  11.  
  12. newMousePosX = point.x
  13. newMousePosY = point.y
  14.  
  15. mouseSpeed = 5
  16.  
  17. while True:
  18.     ctypes.windll.user32.GetCursorPos(pi)
  19.  
  20.     if(newMousePosX != point.x or newMousePosY != point.y):
  21.         if(point.x > newMousePosX):
  22.             newMousePosX += mouseSpeed
  23.         elif(point.x < newMousePosX):
  24.             newMousePosX -= mouseSpeed
  25.  
  26.         if(point.y > newMousePosY):
  27.             newMousePosY += mouseSpeed
  28.         elif(point.y < newMousePosY):
  29.             newMousePosY -= mouseSpeed
  30.  
  31.         ctypes.windll.user32.SetCursorPos(newMousePosX, newMousePosY)
  32.  
What I need help with is the name of the library and name of the functions (to get and set cursor position) in Mac OS X to get the same result.


Regards



Malen
Aug 19 '07 #1
0 2701

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by Ken Favrow | last post: by
1 post views Thread by netquest | last post: by
13 posts views Thread by Roy Smith | last post: by
51 posts views Thread by Reinhold Birkenfeld | last post: by
3 posts views Thread by Tuvas | last post: by
1 post views Thread by marc.wyburn | last post: by
2 posts views Thread by mirandacascade | last post: by
reply views Thread by Jorge Vargas | last post: by
3 posts views Thread by Lucas Prado Melo | last post: by
reply views Thread by devrayhaan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.