4

I am testing applescripts that I will use later in my OSX app. I'm getting a 6 sec delay after the click button command below. After some research it seems that this is a known issue. What I find interesting is, if i use the commercial app QuicKeys to perform the same button click there is no delay, so I assume they found a work around. Anybody have any ideas?

 tell application "System Events"
     tell process "Pro Tools"
         set frontmost to 1
         click button "Track List pop-up" of window 1 
         --  6 seconds delay before next command is sent
         key code 36   -- return key stroke
     end tell
 end tell
4
  • I know this sounds nutty but does it help any if you add a delay 1 command after the click button command?
    – matt
    Apr 21, 2013 at 3:29
  • 1
    No it doesn't,thanks for the suggestion.
    – vcirilli
    Apr 21, 2013 at 20:04
  • It probably won't make a difference, but have you tried replacing click with perform action "AXPress" of? If there is a menu bar item for showing that window?
    – Lri
    Apr 21, 2013 at 23:51
  • 1
    Yes I did, still runs with the delay. thx
    – vcirilli
    Apr 22, 2013 at 3:26

2 Answers 2

2

Was having the same problem and resolved it by enclosing the click causing delay in the ignoring application responses block. Here is a quick summary:

OLD CODE (Causes 6 sec delay)

tell application "System Events" to tell process "SystemUIServer"
    set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
    click bt
    tell (first menu item whose title is "SBH80") of menu of bt
        click
        tell menu 1
            if exists menu item "Disconnect" then
                click menu item "Disconnect"
            else
                click menu item "Connect"
            end if
        end tell
    end tell
end tell

NEW CODE (No delay)

tell application "System Events" to tell process "SystemUIServer"

    set bt to (first menu bar item whose description is "bluetooth") of menu bar 1
    ignoring application responses
        click bt
    end ignoring
end tell

do shell script "killall System\\ Events"
delay 0.1
tell application "System Events" to tell process "SystemUIServer"

    tell (first menu item whose title is "SBH80") of menu of bt
        click
        tell menu 1
            if exists menu item "Disconnect" then
                click menu item "Disconnect"
            else
                click menu item "Connect"
            end if
        end tell
    end tell
end tell

Please check detailed answer in the thread listed below.

Speed up AppleScript UI scripting?

Hope this helps.

1

It seems click or axpress causes a big delay.

Instead - get position and use a third party shell script to do the clicking. Much Much faster.

using clicclik : https://www.bluem.net/en/mac/cliclick/

put in user library/application support/Click

set clickCommandPath to ((path to application support from user domain) as string) & "Click:cliclick"
set clickCommandPosix to POSIX path of clickCommandPath

tell application "System Events"
 tell process "Pro Tools"
     set frontmost to 1
     tell button "Track List pop-up" of window 1 
     set {xPosition, yPosition} to position
        set x to xPosition
        set y to yPosition
    end tell
    do shell script quoted form of clickCommandPosix & " c:" & xPosition & "," & yPosition
     key code 36   -- return key stroke
 end tell

end tell

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.