Reputation: 6372
On a Mac, I'd like to have a keyboard shortcut to open Google Chrome. I know how to set a keyboard shortcut in the system preferences, however I'm unsure how to script it and hook it up.
Is this possible through AppleScript?
Upvotes: 5
Views: 20644
Reputation: 699
Here is a trick. Use Ctrl + ↑ to create a new desktop, say desktop2, and drag chrome application into that new desktop.
Open the keyboard preference pane, switch to the shortcut tab, and select mission control to assign a key to that desktop2. Now you can switch to chrome use that key.
Upvotes: 0
Reputation: 27633
Shortcuts for Automator services might not always work until the service has been selected once from the menu bar. And they won't be available in applications that don't have a Services menu. There's usually also a noticable delay before they are run.
Using a third party application like Alfred or Apptivate would probably be a better idea.
Another option would be assign shortcuts to AppleScripts like this:
tell application "iTunes"
reopen
activate
end tell
Upvotes: 2
Reputation: 4843
If you don't want to use any third party applications you need to create a service and assign it a shortcut.
Open Automator and select Service. You want it to look like the following :
Save it to its default location. ie ~/Library/Services
Open System Preferences --> Keyboard --> Keyboard Shortcuts. Enable the service and assign it a shortcut.
Upvotes: 15
Reputation:
Not with AppleScript alone -- there's no way to bind a keyboard shortcut to execute an arbitrary command.
Instead of writing something yourself, you may want to take a look at some existing launcher applications, like Butler, Spark, or Quicksilver.
Upvotes: 0