Dreamereaper
Dreamereaper

Reputation: 1

Applescript UI check box

I have tried everything that I can think of to check a check box in Apple Script. I am trying to enable Full Keyboard Shortcuts. I know there are Terminal command but when I have been playing around with them they don't work. So, I just want to do this via Apple Script. I have a script written to open up System Preferences and then go to Keyboard. I need to enable "Use all F1, F2, etc. keys as standard keys" then I can handle the rest. I have been working on this for a bit and reaching out here as a last hope I have tried everything. Thank you for your assistance. I am just starting to learning this platform.

tell application "System Preferences"
activate
delay 1
tell application "System Events" to keystroke "Keyboard"
delay 1
tell application "System Events" to keystroke return
delay 3
tell application "System Events" to tell process "Keyboard"
    set theCheckbox to checkbox "Use all F1, F2, etc. keys as standard function keys / When this option is selected, press the Fn key to use the special features printed on each key." of sheet 1 of window 1
    tell theCheckbox
        if not (1) then click theCheckbox
    end tell
end tell
delay 10
tell application "System Events" to keystroke "q" using {command down}

end tell

And I receive this issue.I have tried a TON of variant code.

Upvotes: 0

Views: 974

Answers (1)

jweaks
jweaks

Reputation: 3792

Keyboard panel preferences are not in the System Events dictionary like some of the others, so you do have to resort to UIScripting. You can still open the right anchor tab of the keyboard pref panel programmatically, though. Here's a correct script:

tell application "System Preferences"
    activate
    reveal anchor "keyboardTab" of pane id "com.apple.preference.Keyboard"
end tell

tell application "System Events"
    tell process "System Preferences"
        tell checkbox "Use all F1, F2, etc. keys as standard function keys" of tab group 1 of window 1
            if (get its value) = 0 then click it
        end tell
    end tell
end tell
tell application "System Preferences" to quit

Upvotes: 1

Related Questions