I use a MacBook (shocker…) and I really use it for like programming and stuff.
Given that sometimes I need to toggle the function keys on my keyboard from the nifty volume controls or keyboard lighting to something a tad more useful for extended periods of time…I wrote this simple little AppleScript.
display dialog "Switch up your Function Buttons?" buttons {"Yes", "No"} default button 1 with icon caution
set userChoice to button returned of result
if userChoice = "Yes" then
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 all F1, F2, etc. keys as standard function keys"
--display dialog "Function Key toggled" with icon caution default button 2
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
else if userChoice = "No" then
--don't do squat...
end if
Leave a comment