gingerbeardman Posted March 14, 2019 Share Posted March 14, 2019 (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 March 14, 2019 by gingerbeardman Link to comment
Andrew Posted March 18, 2019 Share Posted March 18, 2019 @GingerbreadMan I'm seeing the same error in ScriptEditor: Link to comment
gingerbeardman Posted March 18, 2019 Author Share Posted March 18, 2019 (edited) 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 March 18, 2019 by gingerbeardman Link to comment
gingerbeardman Posted March 18, 2019 Author Share Posted March 18, 2019 OK, here is a test workflow: https://forumfiles.com/f8J8K7Sdm2/Safari_TEST_alfredworkflow Further checking shows it works OK when called by keyword, but fails by keyboard shortcut? Script Editor works when I invoke using the play button. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now