hey all,
I have written a script “fn” that checks and unchecks the “Use all F1, F2, etc. keys as standard function keys” checkbox, right now I just run it as an application that i put in my dock and finder menu bar, and have been very happy with it so far, it works very quickly, and remains in the background. It also checks if GUI scripting is enabled, if not, then it will simply ask for the Admin password to enable it, if yes, then it moves on to the script.
(*
fn_1.1
Written by circa86 in 2008
This script will simply open the "System Preferences" App, open the Keybaord Preferences Pane, and check/uncheck the "Use all F1, F2, etc. keys as standard function keys" checkbox. If "System Preferences" is already open it will switch to the Keyboard Pane and check the same checkbox. After the box is checked/unchecked, System preferences will quit.
The reason for this script comes from the use of Applications like Maya where F1-12 fn keys are extremely important. I found that I hated going into system preferences to check/uncheck the specific preference each time I wanted to switch the functionality, so this was an excellent solution.
*)
--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
click checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window "Keyboard & Mouse" of application process "System Preferences"
end tell
if application "System Preferences" is running then
tell application "System Preferences" to quit
end if
I would really like to take this a step further and create a script that knows when Maya is running or not, if yes, then the “Use all F1, F2, etc. keys…” checkbox will be checked, if no, then the checkbox will be unchecked. I believe this may be possible but I could really use some help.
also, if I can take that one more step further and create a script that knows what application is in the foreground, if Maya is in the foreground, then check the box, if not then uncheck the box. although that may be somewhat obtrusive as it would still take a moment to run each time I would switch foreground windows, so maybe that is not the best idea.
I am guessing for either of these to function I would need a script to continuously run, is that a bad idea? I am sure that will use atleast some system resources correct?
thanks for taking the time to look over my questions, I appreciate any help.