473,706 Members | 6,565 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
  3. class POINT(ctypes.Structure):
  4.     _fields_ = [("x", ctypes.c_long),
  5.                 ("y", ctypes.c_long)]
  7. point = POINT()
  9. pi = ctypes.pointer(point) 
  10. ctypes.windll.user32.GetCursorPos(pi)
  12. newMousePosX = point.x
  13. newMousePosY = point.y
  15. mouseSpeed = 5
  17. while True:
  18.     ctypes.windll.user32.GetCursorPos(pi)
  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
  26.         if(point.y > newMousePosY):
  27.             newMousePosY += mouseSpeed
  28.         elif(point.y < newMousePosY):
  29.             newMousePosY -= mouseSpeed
  31.         ctypes.windll.user32.SetCursorPos(newMousePosX, newMousePosY)
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.


Aug 19 '07 #1
0 3206

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

Similar topics

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?
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.
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...
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.
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...
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...
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"?
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
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
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...
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
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...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
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...
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.