From 93d80ab2abaa60c378a22c50923053901b7d9b93 Mon Sep 17 00:00:00 2001 From: chrys Date: Mon, 4 Jun 2018 12:30:17 +0200 Subject: [PATCH] add atspi example --- play zone/keypress.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 play zone/keypress.py diff --git a/play zone/keypress.py b/play zone/keypress.py new file mode 100755 index 00000000..7729b464 --- /dev/null +++ b/play zone/keypress.py @@ -0,0 +1,19 @@ +#!/usr/bin/python +import gi +from gi.repository import GLib +gi.require_version('Gst', '1.0') +from gi.repository import Gst +import time, threading +gi.require_version('Atspi', '2.0') +import pyatspi + +# Callback to print the active window on key press amd filter out the key release +def on_key_input(event): + print(event) + +mainloop = GLib.MainLoop() +thread = threading.Thread(target=mainloop.run) +thread.start() +#pyatspi.Registry.registerKeystrokeListener(on_key_input, kind=(pyatspi.KEY_PRESSED_EVENT, pyatspi.KEY_RELEASED_EVENT)) +pyatspi.Registry.registerKeystrokeListener(on_key_input,mask=pyatspi.allModifiers(), kind=(pyatspi.KEY_PRESS,pyatspi.KEY_RELEASE,pyatspi.KEY_PRESSRELEASE), synchronous=True, preemptive=True) +pyatspi.Registry.start()