I'd like to assign basic tasks to the function keys (or other keys if it's easier) on my MacBook. For example I'd like the following to happen when F1 (or whatever key) is pressed:
- Launch Safari
- Open a new window
- Navigate to some specified site
Another example could be:
- Launch Xcode
- Open some specific project
I've experimented with the Automator for things like re-naming dozens of files in a particular directory but I don't know where to start for the above examples.
Best Answer
It's quite easy in OS X 10.6 Snow Leopard, by creating a new service. This is not supported in earlier versions of OS X. For example:
Replace the default with:
Optional: click the Run button to test.
~/Library/Services
.Or, to have the default application open the file or location†:
cat
with: orTo assign a keyboard shortcut, in 10.6:
Unfortunately, it seems that this way Services cannot be assigned a function key (the key is displayed but remains in "edit mode", and when clicking elsewhere, it's lost, which is different from assigning function keys to built-in things like Exposé, or when adding an application shortcut).
To assign a function key, there are two options:
Assume that most applications have a Services menu, and hence will find the name like it appears there. So, if the service is named "Open Super User" then map the menu item Services » Open Super User:
Or, use the command line:
\UF704
, F2 =\UF705
, ..., F6 =\UF709
, F7 =\UF70A
, etc.@
for Command,^
for Ctrl,~
for Option, and$
for Shift.Open Terminal. If the name of the service is
Open Super User
, then to map that service to F1, run:Or for Command-Shift-F12:
To make all running applications aware of the change you made using Terminal:
† There must be some AppleScript version of this as well, but I'm no expert... Anyone?