4

I'm trying to capture left/right/double click events with Python on Windows. Can I do this with win32api?

For example, every time I click somewhere, I want it to print out the exact coordinates of the place it was clicked and what type of click it was.

Someone want to point me in the right direction, please?

2 Answers 2

4

Maybe PyHook is what you are looking for

Sign up to request clarification or add additional context in comments.

Comments

1

Try with this code:

#!/usr/bin/env python
# coordinates.py

import gtk

class Coordinates(gtk.Window):

    def __init__(self):
        gtk.Window.__init__(self)
        self.connect("expose_event", self.expose)
        self.connect("motion_notify_event", self.expose)

    def expose(self, widget, event):
        self.tooltips = gtk.Tooltips()
        x ,y = self.get_pointer()
        self.set_tooltip_text( str(x) + ',' + str(y))
        return False

def main():
    window = Coordinates()
    window.connect("destroy", gtk.main_quit)
    window.show_all()

    gtk.main()

if __name__ == "__main__":
    main()

You can add the appropriate signals for left/right/double click

gtk.window

Events

source

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.