dictation-toolbox/aenea

Errors in natlink console on Mac when iTerm 2 is the current window

dylan-chong opened this issue · 2 comments

screen shot 2017-05-28 at 10 10 02 pm

This error occurs when trying to dictate, or starting up dragon, when iTerm2 is the currently selected window on the Mac side.

It is caused by this code (line 265 of server/osx/server_osx.py).

script = applescript.AppleScript('''
    global frontApp, frontAppName, windowTitle

    set windowTitle to ""
    tell application "System Events"
        set frontApp to first application process whose frontmost is true
        set frontAppName to name of frontApp
        tell process frontAppName
            tell (1st window whose value of attribute "AXMain" is true)
                set windowTitle to value of attribute "AXTitle"
            end tell
        end tell
    end tell

    return {frontAppName, windowTitle}
''')

I will have a play with the script and see if I can default to ignoring AXMain, no guarantees I can fix it

Looks like iTerm2 (or any app without the title bar) means that there is no window whose value of attribute "AXMain" is true. I am working on a script to default to the frontmost window.