Applescript – ignore modifier keys

applescript

I have an applescript that needs to be called by an external program with command-shift-click. However, the applescript then performs keystrokes with command & shift held down. How do I get around this?

I tried:

keystroke "blah" using command up

but get this syntax error:
Expected end of line, etc. but found application constant or consideration.

I've similarly tried

key up shift
key up command
keystroke "blah"

and this simply doesn't work – the command/shift keys are still held.

Is using documented anywhere that might help me resolve this? Otherwise, how do you make the applescript ignore user-held modifier keys?

EDIT: A workaround (but not a solution): https://stackoverflow.com/questions/6584357/why-applescript-always-send-keystrokes-with-command-down add delay 0.2 before the script

Best Answer

Well, hard to prove a negative but, as the question you linked to yourself says: you are holding the and keys down when calling the script. It can not ignore them. Apple script is scripting, and much closer to GUI scripting than to applicative scripting.

I cannot offer any other idea than in the answer to the question you sent: just add a slight delay so that you release the keys before the keystrokes are sent.

delay 0.2