Shortcuts app in macOS has no logic

I'm trying to study music theory and I need a simple series of tasks to be automated to avoid wasting time on repetitive actions. That's what the Shortcuts app is for, but the actions it comes with are either severely mislabeled, or just don't work. I tried to ask for this in some regular forums and nobody could give me a simple answer, so I figured this is something that developers probably know.

I just need four PDFs to open in Preview, their windows moved to one of my monitors, and then be tiled in four equal sizes, with the order determined by me. Sounds easy, doesn't it? But I've been trying to accomplish this for over a year in Shortcuts and even Automator, but at best I can get halfway there.

I've also noticed that the Shortcuts I had prepared are running awfully slow. I'm on a Mac Studio M1 Ultra, and these PDFs are less than 10 MB each, three of them are less than 5 MB. These used to open almost instantly, but now the first one opens, then 3-5 seconds later the next one opens and so on.

As for the window tiling, at best it's tiling three of the windows correctly, but the other one that should tile on the top left, doesn't resize to the quarter of the screen. But worst of all, they are supposed to move to one of the monitors and do the tiling there, but they all open and tile on the main monitor.

So this is one I started today from scratch:

Logically speaking, this should work. But either I'm not following the logic with which Shortcuts was designed, or Shortcuts just doesn't work very well. I'm hoping it's just that I don't follow the logic, but the help is not very helpful. It's rather scant, and other than that, I can't find something that will give me more information about how it works. I'm on the current version of Sonoma, but this was the same in the previous macOS. I doubt it changed at all in Sequoia.

Sorry if I'm asking this in a developer forum, but I figured it's the place where I can finally get some answers after over a year of trial and error and online searching and getting nowhere.

Answered by red_menace in 808409022

Actions are designed to perform a specific task, which is usually general-purpose in nature. They do what they do. I don't know what you did before to get windows moved, but your posted sample workflow isn't going to work at all. Take a look at the action info, which specifies what the input and output will be. Opening files returns files (not windows), and the window actions require a window (not an image) to resize or move, which isn't specified anywhere. Also note that there isn't a line connecting the actions, which indicates they aren't compatible (there isn't anything to convert the action's input/output).

You would need to do something like open the files in Preview, wait a little bit to let them open, then have the Find Windows action filter for Preview windows. From there, you would need to loop through the windows, resizing and moving as desired, but now you are fighting what Shortcuts was designed to be (like a graphical shell script), and might as well use something more designed for the task, like a 3rd party action or scripting.

Shortcuts (and Automator) have their purpose, but they aren't really designed for much beyond batch workflows without some help.

Automator and Shortcuts built-in actions are general-purpose in nature, based mostly on existing shell utilities or common functions, or a developer was generous and decided to include some to support their application. There are tiling and window moving scripts out there (various scripting forums, GitHub, etc), but you would need to graft them into your specific workflow (Run AppleScript, Run Shell script, etc). Other options would be to find 3rd-party actions or make your own, although manipulating the UI is a pain no matter what you use.

So if I understand what you're saying, it's pointless to keep wasting time trying to get Shortcuts to do this, correct?

What I don't understand is this. Basically I have two actions there, repeated 3 times, but if I do just one open action and the move window action, the result is still not good. It keeps opening the file, but it opens it on the left taking up one third of the screen.

But one action is to open the PDF I specified, in the app I specified, so that action works perfectly.

The other action is also as simple as it can be. It tells the system to move the window to the top left, in the specified display. There's also a resize action that is similar but it doesn't allow to specify the display name. So I'm confused as to why the action doesn't do just that?

The action has two components, one is to move the window, but it has to be constrained to the display I put in there. And it just doesn't do that? But I know there's something there that I'm just missing, Apple wouldn't just put that there if it doesn't work at all.

Accepted Answer

Actions are designed to perform a specific task, which is usually general-purpose in nature. They do what they do. I don't know what you did before to get windows moved, but your posted sample workflow isn't going to work at all. Take a look at the action info, which specifies what the input and output will be. Opening files returns files (not windows), and the window actions require a window (not an image) to resize or move, which isn't specified anywhere. Also note that there isn't a line connecting the actions, which indicates they aren't compatible (there isn't anything to convert the action's input/output).

You would need to do something like open the files in Preview, wait a little bit to let them open, then have the Find Windows action filter for Preview windows. From there, you would need to loop through the windows, resizing and moving as desired, but now you are fighting what Shortcuts was designed to be (like a graphical shell script), and might as well use something more designed for the task, like a 3rd party action or scripting.

Shortcuts (and Automator) have their purpose, but they aren't really designed for much beyond batch workflows without some help.

Shortcuts app in macOS has no logic
 
 
Q