Maybe Chris (or anyone of course) knows this off the top of his head. Not a huge deal but I notice if I move too fast executing the macros that include it moves the cells up or down too quickly. Is there anyway to have Keyboard Maestro make sure the AppleScript is finished executing before executing key commands in a macro? QuicKeys seemed to do this very well, meaning that I can have key commands executed in a macro surrounding an AppleScript and it will wait for the AppleScript completed signal before moving on. This way I could just trigger the macro several times (i.e. Command+j, j, j, j and it will do the command four times and make sure everything is done in the right order).
I have noticed multiple times it seems that Keyboard Maestro doesn’t seem to wait for the AppleScript to finish executing and moves ahead if you repeat a macro that includes key commands mixed with AppleScripts.
I have put the key commands in the AppleScript to make sure it executes in the right order like this
> ---------
> delay 0.5
> --Up Arrow
> tell application "System Events" to key code 126 using {shift down}
> tell application "Microsoft Excel"
> tell active window
> set fontColorList to {}
> tell selection
> set valueList to its value
> set rowList to its rows
> end tell
> repeat with i in rowList
> set end of fontColorList to color of font object of i
> end repeat
> set value of selection to reverse of valueList
> set fontColorList to reverse of fontColorList
> set n to 0
> repeat with i in rowList
> set n to n + 1
> set color of (font object of i) to (item n of fontColorList)
> end repeat
> end tell
> end tell
> --Down arrow
> tell application "System Events" to key code 125 using {shift down}
> --Return
> tell application "System Events" to key code 36 using {option down, shift down}
> ------------
The problem with this is you have to put a delay in it and lift up your modifiers each time or you might get other commands executed that use the modifiers. I have even implemented checkModifierKeys in the past but then you have to lift off the modifier keys each time you execute the command.
----------
try
set modifierkeysPressed to true
repeat while modifierkeysPressed
set modifierkeysPressed to (do shell script "/Library/Scripts/checkModifierKeys") is not "0"
delay 0.2
end repeat
on error
display dialog "You do not have 'checkModifierKeys' installed."
end try
----------
In short is there a way to have Keyboard Maestro wait for the AppleScript to finish before starting the repeat command?