1tell application "System Preferences"
2activate
3set the current pane to pane id "com.apple.preference.keyboard"
4reveal anchor "keyboardTab" of pane id "com.apple.preference.keyboard"
5end tell
6
7tell application "System Events" to tell process "System Preferences"
8 delay 0.3
9 set thePopUp to pop up button 2 of tab group 1 of window "Keyboard"
10 set current to value of thePopUp
11 click thePopUp
12 if current is equal to "F1, F2, etc. Keys" then
13 click menu item 1 of menu 1 of thePopUp
14 else
15 click menu item 3 of menu 1 of thePopUp
16 end if
17end tell
18
19quit application "System Preferences"
20