#!/usr/bin/python

import pyatspi

def listener(event):
    try:
        if event.source.getRole() == pyatspi.ROLE_TERMINAL:
            return
    except:
        return

    print (event.source.queryText().getText(0, -1))

pyatspi.Registry.registerEventListener(listener, "object:text-caret-moved")
pyatspi.Registry.start()
