Jump to content

andreavaccari

Member
  • Posts

    1
  • Joined

  • Last visited

Everything posted by andreavaccari

  1. Hi, I have the following AppleScript app that I registered as my default browser: on open location _url tell application id "com.runningwithcrayons.Alfred" to run trigger "open" in workflow "com.andreavaccari.openlink" with argument _url -- delay 5 end open location The workflow that is invoked shows a list filter that allows me to pick which browser and mode to use to open the link. The workflow works correctly when triggered from another workflow or from the command line with `osascript`, but not when triggered from inside the `open location` even handler. What happens in this case is that the Alfred window appears for a split second but closes immediately because the `tell application` instruction is non-blocking and the subroutine ends. I confirmed this by adding a delay (commented above). In this case the window will show for 5 seconds and then close by itself. I found this comment by @deanishe on how to check if Alfred has a window open. This does not work because the `tell application "System Events"` is non-blocking. What is needed is a `repeat` loop that checks inside its body if there search window is open and breaks out otherwise. I have tried tried and failed to find the right AppleScript incantation. The script should look something like this (but again this does not work): on open location _url tell application id "com.runningwithcrayons.Alfred" to run trigger "open" in workflow "com.andreavaccari.openlinkwith" with argument _url repeat tell application id "com.runningwithcrayons.Alfred" if not (exists window 1) then exit repeat end if end tell delay 0.1 end repeat end open location Does anyone know how to achieve this? Thank you in advance for your help!
×
×
  • Create New...