August 21, 2010

Track window and widget events with AT-SPI

« DBus Example | Main | How to embed Jetty Server »

AT-SPI is an abbreviation for Assistive Technology Service Provider Interface. It's an inter-process communication API based on CORBA technologies for assistive issues.

The AT-SPI binding library pyatspi enables developers to track different window or widgets events. The following example describes how to use this library as a daemon and listen to window activate, window deactivate and widget focus events.

import pyatspi

# get the Registry singleton
reg = pyatspi.Registry()

# get desktop
desktop = reg.getDesktop(0)
 
# count of desktops
print "count of desktops: \n", reg.getDesktopCount()

# print all app names
apps = [app.name for app in desktop if app is not None]
print "running apps: \n", apps

# track focus and window events
def eventCallback(event):
   print event

event_identifiers = ['focus', 'window:activate', 'window:deactivate']
# 'monitoring of '
reg.registerEventListener(eventCallback, *event_identifiers)

try:
   pyatspi.Registry.start()
except KeyboardInterrupt:
   pass
 
# cleanup and derigister eventlisteners
pyatspi.Registry.stop()
reg.deregisterEventListener(eventCallback, *what)
 
print 'Done'

Regards
Rafael Sobek

Technorati Tags:

Posted by rafael.sobek at 11:11 AM in Linux

 

[Trackback URL for this entry]

Comment: NV at Mi, 9 Feb 7:20 AM

Hi,

How can I use groovy language (instead of Python) to utilize AT-SPI library?

With Regards, NV

Your comment:

(not displayed)
 
 
 

Live Comment Preview:

 
« August »
SunMonTueWedThuFriSat
1234567
891011121314
15161718192021
22232425262728
293031