Is AppleScript UI Scripting very slow in general, or is it my script, or something else?

前端 未结 2 1573
心在旅途
心在旅途 2020-12-18 09:48

I\'m new to AppleScript, and am just diving into UI Scripting. I\'m attempting to create a script for the program TypeIt4Me, which is a menu bar utility (text expansion) tha

2条回答
  •  情歌与酒
    2020-12-18 09:57

    Your script also takes about 5 seconds to run for me. Delays like that are not very common though.

    This made the script return after about 0.05 seconds, but I couldn't figure out how to run a key code command after it without the delay.

    ignoring application responses
        tell application "System Events" to tell process "TypeIt4Me"
            click menu bar item 1 of menu bar 2
        end tell
    end ignoring
    

    This didn't work either:

    with timeout of 0.2 seconds
        try
            tell application "System Events" to tell process "TypeIt4Me"
                click menu bar item 1 of menu bar 2
            end tell
        end try
    end timeout
    tell application "System Events"
        key code 125
    end tell
    

    Terminating System Events between the commands did work though:

    ignoring application responses
        tell application "System Events" to tell process "TypeIt4Me"
            click menu bar item 1 of menu bar 2
        end tell
    end ignoring
    do shell script "killall System\\ Events"
    delay 0.1
    tell application "System Events"
        key code 125
    end tell
    

提交回复
热议问题