I need to invoke a keyboard shortcut from within an AppleScript code, e.g. Cmd+Ctrl+Opt+E.
I need to invoke a keyboard shortcut from within an AppleScript code, e.g. Cmd+Ctrl+Opt+E.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Sure it works. System events can perform keystrokes. However, keystrokes are always sent to the frontmost application so to perform a shortcut for an application you must tell that app to activate first and then perform the shortcut. For example, I can open a new tab in Safari using command-t. That applescript would look like this…
Now suppose you have a global keyboard shortcut. Global meaning it works from any application. Then you don’t even need to activate an application first, just perform the keystroke. To press the keys you requested do this…