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 post

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 post

Thanks, @vitor

I wasn't aware of the vertical order. With that in mind I solved my issue. Since I'm reusing some of the complex script actions, they have been somewhere on the board.

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.

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