如果是 mac 的话可以用 AppleScript
```
tell application "System Preferences"
set current pane to pane "com.apple.preference.keyboard"
end tell
tell application "System Events"
if UI elements enabled then
tell tab group 1 of window "Keyboard" of process "System Preferences"
click checkbox "Use F1, F2, etc. keys as standard function keys"
end tell
else
tell application "System Preferences"
set current pane ¬
to pane "com.apple.preference.universalaccess"
display dialog ¬
"UI element scripting is not enabled. Check \"Enable access for assistive devices\""
end tell
end if
end tell
tell application "System Preferences"
quit
end tell
```
Alfredworkflow :
https://github.com/packal/repository/blob/master/com.tanseycg.togglefunctionkeys/toggle_function_keys.alfredworkflow