Skip to content

Instantly share code, notes, and snippets.

@thisMagpie
thisMagpie / keystrokes.py
Created May 23, 2013 19:50
Early prototype of keystroke listener.
#!/usr/bin/python
import pyatspi
#Listener pays attention to every press and release
def callback(event):
print ("onKeyPressOrRelease: %s" % (event))
#This will quit listening if F4 is pressed
if event.event_string=='F4':
pyatspi.Registry.stop()
@thisMagpie
thisMagpie / keystrokes.py
Last active December 17, 2015 16:38
This is the (very early) prototype for drag-drop.
#!/usr/bin/python
import pyatspi
#Listener pays attention to every press and release
def callback(event):
desktop = pyatspi.Registry.getDesktop(0)
print ("onKeyPressOrRelease: %s" % (event.event_string))
#This will quit listening if F4 is pressed
@thisMagpie
thisMagpie / heirarchy.py
Last active December 17, 2015 17:39
Yet to grab focus
#!/usr/bin/python
import pyatspi
desktop = pyatspi.Registry.getDesktop(0)
# Listener client pays attention to every press and release
def listen(event):
# This will quit listening if F4 is pressed first statement to exit clean
if event.event_string=='F4':
@thisMagpie
thisMagpie / listen.py
Created May 25, 2013 00:53
earlier test.
#!/usr/bin/python
import pyatspi
# Listener client pays attention to every press and release
def listen(event):
# This will quit listening if F4 is pressed
# Must Perform this check first or exit is not clean
if event.event_string=='F4':
pyatspi.Registry.stop()
@thisMagpie
thisMagpie / gist:5647496
Created May 25, 2013 01:07
heirarchy.py
#!/usr/bin/python
import pyatspi
# Initialise desktop object to the value of the first desktop
desktop = pyatspi.Registry.getDesktop(0)
# Listener client pays attention to every press and release
def listen(event):
@thisMagpie
thisMagpie / Heirarchy.py
Last active December 17, 2015 17:39
cleaner edit but still needs to print out children.
#!/usr/bin/python
import pyatspi
# Initialise desktop object to the value of the first desktop
desktop = pyatspi.Registry.getDesktop(0)
# Listener client pays attention to every press and release
def listen(event):
@thisMagpie
thisMagpie / heir.txt
Created May 25, 2013 02:31
method change and output
#method to get the active window
def get_active_window():
# This will tell us which is the active window
for app in desktop:
for window in app:
return window.getState().contains(pyatspi.STATE_ACTIVE)
#return window
@thisMagpie
thisMagpie / notindent
Created May 25, 2013 02:46
Children not indented
^[OS[magpie@localhost examples]$ python Heirarchy-01.py
[desktop frame | main]
[application | gnome-session]
[application | gnome-settings-daemon]
[application | gnome-shell]
[application | evolution-alarm-notify]
[application | abrt]
[application | gedit]
[application | yelp]
[application | gnome-terminal-server]
->[dialog | Document Statistics]
->[filler | ]
->[filler | ]
->[label | Heirarchy-03.py]
->[filler | ]
->[label | ]
->[panel | ]
->[label | 0]
->[label | 0]
->[label | 0]
@thisMagpie
thisMagpie / Heirarchy.py
Last active December 17, 2015 17:39
Output: ->[dialog | Document Statistics] 1 -->[filler | ] 2 --->[filler | ] 3 --->[filler | ] 3
#!/usr/bin/python
import pyatspi
def on_key_press(event):
# Must Perform this check first or exit is not clean
if event.event_string=='F4':
pyatspi.Registry.stop()
if event.event_string =='F3':
print_tree(0,active_window())