Check this out:
It uses the Accessibility APIs (i.e: it's not a hack) and the code is
available at Github.
Right now it doesn't work with Mail.app, but maybe somebody could help
Jesse improve QuickCursor so we can finally ditch "Edit in TextMate" :