#!/usr/bin/python3

import pyatspi

def caretMoved(e):
    print("caret at position ", e.detail1)

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

