I have written an Applescript to change screen resolutions. I have converted it to an APP. When I click on the icon, it works perfectly. However, I would like to assign it to a keypress. I have read tons of postings on the internet and I cannot get it to work. I am using High Sierra, but am wondering if this is the problem. Despite various not assigned key presses such as a four key press, still no luck. Here is what I have done:

  • Enabled Automator in Accessibility Services.
  • Saved my compiled script through Automator as an App. (works fine).
  • Opened Keyboard Shortcuts, and TRIED to add the app as a service, but adding doesn't seem to show up. Seems like one time it did, but still didn't work.
  • Opened Keyboard Shortcuts, and added to to Applications, and designate the keypress, but no go. It won't work

I have been told that if I add it to ~/library/services it will work but there are two folders:

System > Library > Services but this is locked and I tried to change the permissions and despite the fact that I am the only one on the computer, it says I don't have enough rights. Its my computer.. what gives?

Users > Lad > Library (hidden) > Services: added the apps. They do not show up on the Keyboard Shortcuts choices.

Am I doing something wrong?



Instead of converting your Applescript into an app, turn it into an Automator Service.

Open automator. When prompted to choose a type of document, select "Service". Afterwards, change the dropdowns so the sentence at the top of the screen reads: "Service receives no input in any application"

Next, drag the Run Applescript action into your workflow (it's under utilities), remove the pre-populated "on run [...] end run" code (since you have no input), and paste your Applescript into the box. Lastly, save and name your service.

You can now set up a keyboard shortcut for your service in Settings → Keyboard → Shortcuts → Services.

You could also create an automator service that does nothing but launch a specific app, and assign that service to a keyboard shortcut. In this case, the code for the AppleScript portion of the automator service would be: do shell script "open [path to app]"

  • While i know this answer to be correct, it's late and I'm tired, so it's not particularly well formatted. Any improvements on that front would be welcome. Otherwise, I'll likely fix it up at some point... – Wowfunhappy Jun 17 '18 at 2:38
  • OK.. I did that. Found the service in the Keyboard Shortcuts.. Assigned a keypress combination to it... nothing.. nada. What next? – Stephen Jun 17 '18 at 4:00
  • Follow general debugging/troubleshooting steps. Without access to the machine, I can't tell you exactly what to do, but here are some things I might try: Does the "service running" gear appear in the menubar? Can you launch the service from the menubar? Does the service work when run inside Automator? Do keyboard shortcuts work for other automator services? Can you add log statements to the AppleScript to see exactly what it's doing (or not doing)? – Wowfunhappy Jun 17 '18 at 21:14
  • The script runs flawlessly in Automator. Here is the lores.script. Its short: tell application "System Preferences" reveal anchor "displaysDisplayTab" of pane "com.apple.preference.displays" end tell tell application "System Events" to tell process "System Preferences" click radio button "Display" of tab group 1 of window "iMac" click radio button "Scaled" of radio group 1 of tab group 1 of window "iMac" select row 2 of table 1 of scroll area 1 of tab group 1 of window "iMac" end tell I dont think I have seen a gear in the menu bar. – Stephen Jun 18 '18 at 0:02
  • And yes, another service that I created in Automator (open a blank text file), works just fine when I assign it a press in keyboard shortcuts. – Stephen Jun 18 '18 at 0:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .