I've had to rethink this - the preference I'm working with (the one in the Keyboard prefpane that tells OSX whether to call up Help or dim your screen when you hit F1 as opposed to Fn+F1 on some mac keyboards) is in .GlobalPreferences.plist but is held in ram once loaded. So there's no point in me editing the .plist file, what I need to do instead is find out what the OSX variable is that holds this value, so I can switch it.

Meanwhile, I've put together an AppleScript that uses the GUI to do the work, and pops up a brief message about the switch state afterwards. This works fine, except if I trigger it using iKeys, I get an annoying Run/Cancel dialogue first - not sure why that is.

Anyway, in case anyone's interested, here's the script:

Code:

(* script to switch on/off "Use all F1, F2, etc. keys as standard function keys" *)
set resultString to ""
tell application "System Preferences"
activate
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"
if value of checkbox 1 is 0 then
click checkbox 1
set resultString to "F1, F2, etc. set as function keys"
else
click checkbox 1
set resultString to "F1, F2 etc. set as media controllers"
end if
end tell
else
tell application "System Preferences"
activate
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
delay 0.5
tell application "System Preferences"
quit
end tell
if resultString is not "" then display dialog resultString buttons {"•"} giving up after 2.5

Xplain's use of MacNews, AppleCentral and AppleExpo are not affiliated with Apple, Inc. MacTech is a registered trademark of Xplain Corporation. AppleCentral, MacNews, Xplain, "The journal of Apple technology", Apple Expo, Explain It, MacDev, MacDev-1, THINK Reference, NetProfessional, MacTech Central, MacTech Domains, MacForge, and the MacTutorMan are trademarks or service marks of Xplain Corp. Sprocket is a registered trademark of eSprocket Corp. Other trademarks and copyrights appearing in this printing or software remain the property of their respective holders.

All contents are Copyright 1984-2010 by Xplain Corporation. All rights reserved. Theme designed by Icreon.