winterflags Posted August 23, 2016 Share Posted August 23, 2016 (edited) Edit: I realized that the thread topic is ambiguous. The problem I'm having is that including a certain AppleScript in my Alfred workflow makes the Alfred bar behave weird, refusing to go away. I've made a workflow that uses a List Filter to open a set of URLs depending on the argument provided. I also included an AppleScript that tells Evernote to open a certain notebook/stack. The script is visible as the /usr/bin/osascript in the image below. When I run the workflow with the AppleScript attached to it, the Alfred Input Window closes but then displays again – with the previous input still there. It behaves very erratically each time, sometimes "blinking" on/off in perpetuity, which seems to be impossible to stop, except by rebooting the computer. When I run the workflow without the Applescript attached, the Alfred Input Window closes normally. Something seems to force the Alfred window to remain open. Is it a bug in Alfred, or something with the AppleScript and how it's implemented in the workflow? Note that I didn't write the AppleScript myself, but it was retrieved from the forum link above. I understand that this isn't the proper forum for AppleScript support – but is Alfred behaving in an unexpected way here? Thanks for any help! on run argv set destination to "stack:Communications" tell application "System Events" -- Let's make sure Evernote is running. If Evernote needs to be started, wait a sec! if not (exists process "Evernote") then tell application "Evernote" to activate delay (3) end if -- Now let's invoke a collection window by starting a global search. keystroke space using {option down} delay (0.5) end tell -- Sometimes it needs a moment for a collection window to be created. -- As long as no collection window exists, trying to change its query string will result in an error. -- We'll simply try again until we succeed. repeat set tryagain to true try tell application "Evernote" set query string of window 1 to destination end tell set tryagain to false on error tell application "System Events" keystroke space using {option down} end tell delay (1) set tryagain to true end try if not tryagain then exit repeat end repeat end run Edited August 23, 2016 by winterflags Link to comment
dfay Posted August 23, 2016 Share Posted August 23, 2016 Are you using option-space as your hotkey for Alfred? The script is trying to get Evernote to do something by simulating an option-space keypress in System Events. deanishe 1 Link to comment
winterflags Posted August 24, 2016 Author Share Posted August 24, 2016 Are you using option-space as your hotkey for Alfred? The script is trying to get Evernote to do something by simulating an option-space keypress in System Events. Keen observation! That solved my problem, thanks. Funny coincidence that they were using the same key combination, so I changed the one used in Evernote. dfay 1 Link to comment
dfay Posted August 25, 2016 Share Posted August 25, 2016 Oh good. I've spent way too much time debugging AppleScripts that use various key presses, so when I saw the keystroke command there, it looked like a likely culprit 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