Jump to content

Preference script not working within alfred


Jadkh

Recommended Posts

Hello! 
I found an AppleScript that allow to check and uncheck the "Use F1, F2 etc. as standard function keys" in the keyboard prefpane.

I check the security preferences and Alfred is check in the accessibility tab. 
When I run it inside Script Editor it works but when running in alfred workflow editor I get errors. 
Could somebody help me ? 
Thanks :)

Jad

[INFO: alfred.workflow.trigger.hotkey] Processing output 'alfred.workflow.action.applescript' with arg ''
[ERROR: alfred.workflow.action.applescript] {
    NSAppleScriptErrorAppName = "System Events";
    NSAppleScriptErrorBriefMessage = "Can\U2019t get checkbox 1 of tab group 1 of window 1 of process \"System Preferences\". Invalid index.";
    NSAppleScriptErrorMessage = "System Events got an error: Can\U2019t get checkbox 1 of tab group 1 of window 1 of process \"System Preferences\". Invalid index.";
    NSAppleScriptErrorNumber = "-1719";
    NSAppleScriptErrorRange = "NSRange: {90, 47}";
}

Here is the small script in question: 

tell application "System Events" to tell process "System Preferences"
click checkbox 1 of tab group 1 of window 1
end tell
quit application "System Preferences"
Edited by Jadkh
Link to comment

AppleScript is weird, and behaves differently when run in different ways.

If you're using a Run NSAppleScript action, try using a normal Run Script action with Language = "osascript (AS)" instead. You can also try saving the script in the workflow directory and running it via bash : osascript myscript.scpt

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...