Skip to content

Instantly share code, notes, and snippets.

@alex-cory
Created March 21, 2014 07:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alex-cory/541db4e4218a67db51c4 to your computer and use it in GitHub Desktop.
Save alex-cory/541db4e4218a67db51c4 to your computer and use it in GitHub Desktop.
applescript to toggle the fn key
--Check if GUI Scripting is Enabled
tell application "System Events"
if not UI elements enabled then
set UI elements enabled to true
end if
end tell
--Enable/Disable "Use all F1, F2, etc. keys as standard function keys" option in Keyboard & Mouse Preference pane and close System Preferences
tell application "System Events"
tell application "System Preferences"
reveal anchor "keyboardTab" of pane "com.apple.preference.keyboard"
end tell
set bbox to checkbox 1 of tab group 1 of window 1 of application process "System Preferences"
click bbox
set b to value of bbox
if b is 0
set q to "Apple"
else
set q to "Fn"
end if
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
return q
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment