You are not logged in.

#1 2005-11-03 06:57:24

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Python and mouse events

I want to be able to take all mouse events (motion, button click) and store them. Of course, I want to do this using Python. I don't know how to do this such that I can receive *all* mouse events, not just those that occur over, for example, a gtk window. I don't care what happens to the window under the pointer when the click occured, I just want to log that the click happened and at what coordinate.

Is this possible using a lowlevel Python API that will work on both Linux and Windows? What about Java? I'm not doing it in C.

Reason for project: I have to write some code that uses some very unique hardware that sends input location and button press events into a network socket. I want to test my code using traditional input devices (ie: mouse), so I want to capture mouse events and forward them in the correct format across the socket.

Its 2AM and I have no clue how to do this or where to start looking. Some kind of interrupt API???

thanks,

Dusty

Offline

#2 2005-11-03 15:29:44

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python and mouse events

python-xlib will work just fine.  You're going to have to do a server-wide grab for mouse events, and then resend the events to the window the occured on in order to do what you're intending.

Offline

#3 2005-11-03 17:04:14

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Python and mouse events

Dusty wrote:

l Python API that will work on both Linux and Windows

I don't think python-xlib will work on Windows?  Problem is I want this simulator to work on my system, and on my unenlightened friends' windows systems.

Maybe its not as easy as I hoped.

Dusty

Offline

#4 2005-11-03 19:34:09

phrakture
Arch Overlord
From: behind you
Registered: 2003-10-29
Posts: 7,879
Website

Re: Python and mouse events

Dusty wrote:
Dusty wrote:

l Python API that will work on both Linux and Windows

I don't think python-xlib will work on Windows?  Problem is I want this simulator to work on my system, and on my unenlightened friends' windows systems.

Maybe its not as easy as I hoped.

Dusty

Nope it's not - mouse events that are not within the scope of the application window are not natively handled by python, as far as I know.  You'd have to hack something together... I could do the linux side... as for windows, no idea.

Offline

#5 2005-11-04 00:51:45

Dusty
Schwag Merchant
From: Medicine Hat, Alberta, Canada
Registered: 2004-01-18
Posts: 5,986
Website

Re: Python and mouse events

was thinking I'd have to handle the interrupts directly, but I suspect that's done different for both OS too. So lets not bother.

Dusty

Offline

Board footer

Powered by FluxBB