By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
464,330 Members | 1,144 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 464,330 IT Pros & Developers. It's quick & easy.

Accesing mouse library functions with ctypes in Mac OS X

P: 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
Share this question for a faster answer!
Share on Google+

Post your reply

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