Answers:
要进行以下工作,您需要在系统偏好设置»通用访问中启用辅助设备的访问权限。
打开Automator,选择Service并选择该服务不接收任何输入(靠近顶部)。
双击库中“ 实用工具”类别中的“运行AppleScript ”。使用以下内容替换新创建的操作的默认代码段:
tell application "System Preferences"
set current pane to pane id "com.apple.preference.keyboard"
tell application "System Events"
tell process "System Preferences"
click checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window "Keyboard"
end tell
end tell
quit
end tell
系统偏好设置将启动,但不会显示,并会在切换设置后立即退出。
按Command-S
保存,给它命名,例如Toggle Fn。结果:
转到系统偏好设置»键盘»键盘快捷键»服务,为此服务指定键盘快捷键。
~/Library/Services
。也许你可以手动复制这个?要配置“服务”菜单,请使用ServiceScrubber。
scpt
文件~/Library/Scripts
并从菜单栏调用。使用第三方FastScripts,您可以指定键盘快捷键。
我知道这篇文章很老但是无法在Mountinan Lion上运行。我发现了一个类似的片段,但删除了一些不必要的部分。
tell application "System Preferences"
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
-- If we don't have UI Elements enabled, then nothing is really going to work.
if UI elements enabled then
tell application process "System Preferences"
get properties
click radio button "Keyboard" of tab group 1 of window "Keyboard"
click checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window "Keyboard"
end tell
tell application "System Preferences" to quit
else
-- GUI scripting not enabled. Display an alert
tell application "System Preferences"
activate
set current pane to pane "com.apple.preference.universalaccess"
display dialog "UI element scripting is not enabled. Please activate \"Enable access for assistive devices\""
end tell
end if
end tell
希望这可以帮助
你也可以使用KeyRemap4MacBook这样的private.xml:
<?xml version="1.0"?>
<root>
<item>
<name>test</name>
<identifier>test</identifier>
<autogen>__KeyToKey__ KeyCode::F1, VK_COMMAND | ModifierFlag::NONE, KeyCode::VK_CONFIG_TOGGLE_fn</autogen>
<autogen>__KeyToKey__ KeyCode::BRIGHTNESS_DOWN, VK_COMMAND | ModifierFlag::NONE, KeyCode::VK_CONFIG_TOGGLE_fn</autogen>
</item>
<item>
<name>fn</name>
<identifier vk_config="true">fn</identifier>
<autogen>__KeyToKey__ KeyCode::BRIGHTNESS_DOWN, KeyCode::F1</autogen>
<autogen>__KeyToKey__ KeyCode::BRIGHTNESS_UP, KeyCode::F2</autogen>
<autogen>__KeyToKey__ KeyCode::EXPOSE_ALL, KeyCode::F3</autogen>
<autogen>__KeyToKey__ KeyCode::LAUNCHPAD, KeyCode::F4</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::KEYBOARDLIGHT_LOW, KeyCode::F5</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::KEYBOARDLIGHT_HIGH, KeyCode::F6</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::MUSIC_PREV, KeyCode::F7</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::MUSIC_PLAY, KeyCode::F8</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::MUSIC_NEXT, KeyCode::F9</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::VOLUME_MUTE, KeyCode::F10</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::VOLUME_DOWN, KeyCode::F11</autogen>
<autogen>__ConsumerToKey__ ConsumerKeyCode::VOLUME_UP, KeyCode::F12</autogen>
<autogen>__KeyToKey__ KeyCode::F1, KeyCode::BRIGHTNESS_DOWN</autogen>
<autogen>__KeyToKey__ KeyCode::F2, KeyCode::BRIGHTNESS_UP</autogen>
<autogen>__KeyToKey__ KeyCode::F3, KeyCode::EXPOSE_ALL</autogen>
<autogen>__KeyToKey__ KeyCode::F4, KeyCode::LAUNCHPAD</autogen>
<autogen>__ConsumerToKey__ KeyCode::F5, ConsumerKeyCode::KEYBOARDLIGHT_LOW</autogen>
<autogen>__ConsumerToKey__ KeyCode::F6, ConsumerKeyCode::KEYBOARDLIGHT_HIGH</autogen>
<autogen>__ConsumerToKey__ KeyCode::F7, ConsumerKeyCode::MUSIC_PREV</autogen>
<autogen>__ConsumerToKey__ KeyCode::F8, ConsumerKeyCode::MUSIC_PLAY</autogen>
<autogen>__ConsumerToKey__ KeyCode::F9, ConsumerKeyCode::MUSIC_NEXT</autogen>
<autogen>__ConsumerToKey__ KeyCode::F10, ConsumerKeyCode::VOLUME_MUTE</autogen>
<autogen>__ConsumerToKey__ KeyCode::F11, ConsumerKeyCode::VOLUME_DOWN</autogen>
<autogen>__ConsumerToKey__ KeyCode::F12, ConsumerKeyCode::VOLUME_UP</autogen>
</item>
</root>