#!/usr/bin/python3
# based off https://wiki.documentfoundation.org/Development/Accessibility
 
import pyatspi
import time
 
def onEvent(e):
    print("--- %s\n%s" % (time.strftime('%X'), e))

types = [ "object:", "window:", "focus:", "mouse:" ]

for t in types:
    pyatspi.Registry.registerEventListener(onEvent, t)

try:
    pyatspi.Registry.start()
except KeyboardInterrupt:  # meh, doesn't work
    pass
finally:
    for t in types:
        pyatspi.Registry.deregisterEventListener(onEvent, t)
