On 20-11-10 00:06, [email protected] wrote:
Hi,

Below is a question from Jan Martinek sent back in 2006.  I am trying
to do the same thing, I haven't found anywhere on the web how to do
it.

The summary is I want to catch all mouse and/or keyboard events
anywhere on the screen?  I tried what Jan did except assigned w with

w = gtk.gdk.get_default_root_window()
This will return a gtk.gdk.Window, not a gtk.Window as in the example you posted.

http://library.gnome.org/devel/pygtk/stable/class-gdkwindow.html#function-gdk--get-default-root-window

which worked fine, but the

w.connect('motion-notify-event', wakeup)

failed with a message along the lines of 'for gtk.gdk.Window unknown
signal motion-notify-event' (sorry can't remember the exact message,
and i'm away from my desktop).
A gtk.gdk.Window doesn't have this signal, check the docs for info: http://library.gnome.org/devel/pygtk/stable/class-gdkwindow.html

Maybe this post will help you a bit: http://www.mail-archive.com/[email protected]/msg19101.html

Cheers,
Timo

I can't find what signals are valid for a gtk.gdk.Window.  And even if
I could, I still need it to with the 'motion-notify-event'.

Thanks for any clues!

Matt

Hello,

please, does anyone know how to catch all keyboard and mouse events
regardless of main window state? If I try this

#!/usr/bin/env python
import gtk

def wakeup(widget, event):
    print"Event number %d woke me up" % event.type

w = gtk.Window()

w.add_events(gtk.gdk.KEY_PRESS_MASK |
              gtk.gdk.POINTER_MOTION_MASK |
              gtk.gdk.BUTTON_PRESS_MASK |
              gtk.gdk.SCROLL_MASK)

w.connect("motion-notify-event", wakeup)
w.connect("key-press-event", wakeup)
w.connect("button-press-event", wakeup)
w.connect("scroll-event", wakeup)

w.show()

gtk.main()


then it responds to keypresses only if the window is active. Mouse events
are catched only when the cursor is placed within the window.

How can I catch all the events even when the window is
inactive/minimalized/hidden? Do you know any application that must be able
to do this? For example

- applets measuring distance travelled by mouse cursor
- typing-break applications that notify the user that he typed for a long
   period of time a should have a rest.
- something that monitors user's activity/inactivity (various IM clients?)
- "xeyes" - eyes that always look at the mouse cursor
- keyloggers - malicious programs (if there are any) sniffing keystrokes
   (mainly passwords) and logging them into a file.
- ???

I am looking for something written in pure GTK (no direct xlib calls) so
that I could learn from the source code.

Thank you
Jan Martinek


_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

_______________________________________________
pygtk mailing list   [email protected]
http://www.daa.com.au/mailman/listinfo/pygtk
Read the PyGTK FAQ: http://faq.pygtk.org/

Reply via email to