Jump to content

How can I force a workflow to run sequentially?


Recommended Posts

I have a workflow that starts up several apps / windows and calls a run script action after each to place it.

In one of my current workflows I'm opening 2 separate Safari windows and want to place them side by side.

The Hotkey triggers several Arg and Vars actions (setting the position for the application - 2 of them are for the Safari windows), which call a Run NSAppleScript to open a URL in Safari (or opening the corresponding window if it is already open), followed by a Run Script to place the window (via hammerspoon).

It seems that the Arg and Vars and/or NSAppleScript actions run somehow in parallel because when the placement action of the first Safari window wants to place the window, it can only look for the frontmost "Safari" window which turns out to be secondly opened window already most of the times.

Is there any way to tell the workflow to please finish one path before continuing with the next to avoid mismatch?

Link to comment

In Alfred Preferences, in the Workflows tab, click the + on the bottom left (next to Help) and go Getting Started → Stream Order. That explains the control flow.


But you’re unlikely to achieve success that way, because the way GUI automation (your resizing) tends to work is that the command is sent and returns, it doesn’t wait to get a response before continuing. Your best best is to chain those sequentially, not separately. If you really need them to be separate, you’ll need to add delays to give actions time to process. That can be somewhat error-prone, but so is GUI automation.

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...