473,320 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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 3149

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

Similar topics

1
by: Ken Favrow | last post by:
Is there a way I can control the mouse with python? I need to be able to navigate and click in other applications based on vectors sent from my program. Basically a mouse macro type thing. any...
1
by: netquest | last post by:
Hi, I have a tiny script that launches an instance of Internet Explorer. Is it possible for me to also change the mouse pointer, for that application or even the desktop, to a transparent...
13
by: Roy Smith | last post by:
I've got a C library with about 50 calls in it that I want to wrap in Python. I know I could use some tool like SWIG, but that will give me a too-literal translation; I want to make some...
51
by: Reinhold Birkenfeld | last post by:
Hello, at the moment python-dev is discussing including Jason Orendorff's path module into the standard library. Do you have any other good and valued Python modules that you would think are...
3
by: Tuvas | last post by:
I am writing a program that mimics a program written in C, but using Python-supiorior techniques. The C program calles a library function, non-open source, I only know that it sends it a command...
1
by: marc.wyburn | last post by:
hi all and before I start I apologise if I have this completely muddled up but here goes. I'm trying to call functions from a dll file in a python script but I can't work out what functions are...
2
by: mirandacascade | last post by:
I am prompted to make these inquiries after seeing the following link to ctypes: http://docs.python.org/lib/module-ctypes.html in which ctypes is described as a foreign function library. ...
0
by: Jorge Vargas | last post by:
Hi I'm having an issue with ctypes loading libraries. I got the following setup. I have a library (coded by me) that calls a external library (installed with the package manager), and my...
3
by: Lucas Prado Melo | last post by:
I would like to control mouse events (i.e. I would like to "click" and move mouse around by code). How do I do this in python? regards
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.