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

Change Applescript Actions Based On Key?

I'm writing an Applescript, and distributing it to many different people. What I want it to do is go through the actions normally, but if the "C" key is held down, it goes to the config window. I'm running Mac Os 10.7.5, normal Applescript. What I have so far is:



tell application "System Events"
  
                    try
  
                              if keystroke "C" is down then
  
                                        beep 5
  
                              end if
  
                    on error
  
                    end try
  
          end tell


It compiles and runs, but doesn't react when I press the "C" key, even when I set it to endlessly repeat. Is there a working version of this?

Posted on Apr 10, 2013 6:05 AM

Reply
Question marked as Best reply

Posted on Apr 10, 2013 7:24 AM

The System Events keystroke command is for sending keystrokes, not receiving or looking for key presses. Regular AppleScript is not really designed for things like this, so you will need to use other tools. There is a shell script to check for modifier keys (for example, look for the option key instead of the C key) - take a look at this MacScripter post.

2 replies
Question marked as Best reply

Apr 10, 2013 7:24 AM in response to Apple_For_The_Win

The System Events keystroke command is for sending keystrokes, not receiving or looking for key presses. Regular AppleScript is not really designed for things like this, so you will need to use other tools. There is a shell script to check for modifier keys (for example, look for the option key instead of the C key) - take a look at this MacScripter post.

Change Applescript Actions Based On Key?

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