Jump to content
gingerbeardman

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

Recommended Posts

Posted (edited)

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

Share this post


Link to post

Well, the example was just that. It will not work in circumstances where the layout of the Safari toolbar is different, which I suspect is the case for you?

 

But I'll confirm the OP and post more details when I can.  

Edited by gingerbeardman

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...