0

I need to perform the following task on Mac OS X:

  1. Find an application window that user is currently working in

  2. Find a currently focused element within it

  3. If the element is text editable, find current cursor position

I'd like to use ATOMac, but I cannot figure out how to do this, i.e. what are correct attributes etc. Any ideas?

Vasily Ryabov
  • 9,386
  • 6
  • 25
  • 78
Dalen
  • 4,128
  • 1
  • 17
  • 35

1 Answers1

0
from atomac import getFrontMostApp

def GetInsertionPoint ():
    try: app = getFrontmostApp()
    except: return -1
    for element in app.textFieldsR()+app.textAreasR():
        if element.AXFocused:
            return element.AXSelectedTextRange[0]
    return -1
Dalen
  • 4,128
  • 1
  • 17
  • 35