Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

How to tell System Events *not* to use modifier key?

Hi,

I am having the following problem. I have an AppleScript script for Pages that I want to trigger with a keyboard shortcut involving the Command key. (I am using Keyboard Maestro for this, but the same problem applies when I use FastScript.)

The problem is that the script in question contains a step where I tell System Events to tell Pages to type a key. And I want Pages to type the key WITHOUT any modifier key:

<pre>
tell application "System Events" to tell application process "Pages"
key code 36
end tell
</pre>

But the script executes so fast that by the time it reaches this step, half of the time my finger has not quite released the Command key that I pressed for the keyboard shortcut to trigger the script. And when that happens System Events still treats the Command key as being down and so executes "key code 36" as if it were "key code 36 using command down".

But I don't want this! Whether I have released the Command key yet or not, I want the script to always execute "key code 36" without a modifier key.

Is this possible?

I can't find any reference to this particular problem.

Of course, when I run the script by invoking it with something that involves the mouse, there is no problem whatsoever. But that's not a solution. I want to be able to invoke the script with the a keyboard shortcut.

I could also use a keyboard shortcut that doesn't involve a modifier key, like an Fkey, but that would not be the most convenient for me.

And I could probably add a pause in the script to wait until my finger has released the modifier keys. But that strikes me as particularly inelegant, considering that I am a fast typist and wants all my commands, including this one, to execute as fast as possible.

So, basically, my question is: Is there a way to make this "key code 36" command execute in a way that ignores whatever modifier keys might still be halfway down? I naively tried "key code 36 not using command down" and "key code 36 using command up", but neither worked for me.

I would appreciate feedback on this.

Mac Pro 2x2.26, Mac OS X (10.6.3)

Posted on Apr 2, 2010 1:48 PM

Reply
5 replies

Apr 4, 2010 6:04 AM in response to Andreas 

Thanks for the Extra Suites suggestion.

However, even if it offends my sense of elegance somewhat, I think I'd rather go with

<pre>
delay 0.5
</pre>

than to purchase a $10 addition which will undoubtedly add to the complexity of my setup.

delay 0.5 seems to be doing the trick. I guess I just have to get used to the limitations of AppleScript itself.

How to tell System Events *not* to use modifier key?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.