473,792 Members | 3,042 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Accesing mouse library functions with ctypes in Mac OS X

1 New Member
Hi all!


I'm building mouse movement filter program for Windows and Mac OS X. In Windows I use ctypes.windll.u ser32.getCursor Pos(pointer) and ctypes.windll.u ser32.setCursor Pos(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 3220

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

Similar topics

1
15128
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 help?
1
3753
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 bitmap of my choosing? If so, hints on where to start are welcome. My intention is to have a circle or a rectangle for the cursor. Thanks.
13
3862
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 modifications along the way to make the interface more Pythonic. For example, all of these functions return an error code (typically just errno passed along, but not always). They all accept as one of their arguments a pointer to someplace to store...
51
3035
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 bug-free, mature (that includes a long release distance) and useful enough to be granted a place in the stdlib? For my part, ctypes seems like a suggestion to start with.
3
1672
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 LINUX_CAN_Open() as for a few others as well. Is there a way I can call this function from Python without opening the code, as the library is not open sourced (I know, a rarity with Linux libraries, but, well, it appears not to be...)? Perhaps...
1
10344
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 available. I'm using ctypes. I've tried using dir(ctypes_object) but the resultant output looks like a list of standard functions and not the ones I'm looking for. Also how can I tell if the dll was written in C or C++ as I understand C++ dlls...
2
1622
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. What is the definition of "foreign function library"? Is the concept different from a "package"? Is the concept different from a "module"?
0
1034
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 ctypes program calls my lib. at first python couldn't find my lib but setting LD_LIBRARY_PATH=. fix that, but now it's failing inside my lib because it can't find the
3
2153
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
9670
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9518
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10211
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9033
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5560
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4111
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3719
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2917
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.