You can run an AppleScript (e.g. by wrapping it in a Service in Automator with the Run AppleScript action, with no input in Terminal) that executes the following:
tell application "System Events"
tell expose preferences to set the properties of the all windows shortcut to {function key:F1}
key code 101 # press F9
tell expose preferences to set the properties of the all windows shortcut to {function key:F9}
end tell
This will temporarily assign a different shortcut to what's bound to F9, press F9, and revert the setting. The setting names are the following for the other Expose preferences:
all windows shortcut
application windows shortcut
show desktop shortcut
dashboard shortcut
The key codes for F9 to F12 are the following:
F9 101
F10 109
F11 103
F12 111
You can assign keyboard shortcuts to services in System Preferences » Keyboard » Keyboard Shortcuts » Services You will need to learn another shortcut (e.g. Command-F9
), but at least you can press a key to initiate the action. For shortcuts using F-keys, see the last paragraph in this answer.
You can alternatively configure a hotkey/macro application like Butler to press the escape sequence you get from cat -v
when pressing one of the F-keys while you deactivated the shortcuts.
$ cat -v
^[[20~^[[21~^[[23~^[[24~
These are F9 to F12, in order.
In Butler, it looks like this for F9:
I pressed Ctrl-[
, [
, 2
, 0
, ~
for that sequence. On my keyboard layout, ~
is Shift-backtick
, that's why the Shift modifier is visible. Works anyway.
Configure a shortcut and you can start pressing that to get the escape sequence:
Works in mc
, and I don't recall another CLI program with F-keys at the moment. But it's not the mc
specific escape sequence, so it will probably work in others.
Alternatively, many command line applications understand Esc, 1
(sequence) to mean F1
, through to Esc, 0
meaning F10
.
On MacBook Pro running Yosemite, fn-Cmd-F9 works; fn-Opt-F9 just inserts tilde. (I'm using it within emacs.) – Chap – 2015-01-09T21:28:37.337
On my MacBook Air running Mavericks, it's fn-Option-Fkey, not fn-Command-Fkey. – Mark Reed – 2014-05-08T01:19:40.330