Jump to content

AppleScript not running in Alfred but does run in Script Editor?


Recommended Posts

The following AppleScript runs just fine in Script Editor (it clicks a user extension button of given description)

tell application "System Events"
	tell process "Safari"
		set extDesc to "Recent Tab List"
		
		tell first UI element of last group of last toolbar of first window
			click (first button where its description = extDesc)
		end tell
	end tell
end tell

...but nothing happens when I call it from within an Alfred workflow? Using either NSAppleScript or /usr/bin/osascript

 

Errors are:

[2019-03-14 11:47:19][ERROR: action.applescript] {
    NSAppleScriptErrorAppName = "System Events";
    NSAppleScriptErrorBriefMessage = "Can\U2019t get toolbar 1 of window 1 of process \"Safari\". Invalid index.";
    NSAppleScriptErrorMessage = "System Events got an error: Can\U2019t get toolbar 1 of window 1 of process \"Safari\". Invalid index.";
    NSAppleScriptErrorNumber = "-1719";
    NSAppleScriptErrorRange = "NSRange: {194, 57}";
}

[2019-03-14 11:47:19][ERROR: action.script] /Users/matt/Library/Caches/com.runningwithcrayons.Alfred-3/Workflow Scripts/C0150784-A54F-47EA-B559-C0306F7759D7:186:243: execution error: System Events got an error: Can’t get toolbar 1 of window 1 of process "Safari". Invalid index. (-1719)

 

Any ideas?

Edited by gingerbeardman
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...