How can I get automator to select the correct already open document? I should start by mentioning that I have an app that opens on start-up which allows me to set customized shortcuts and gestures.
In my case:

command+alt+j maximizes the selected window.
command+alt+n maximizes the selected window on the left portion of the screen.
command+alt+m maximizes the selected window on the right portion of the screen.



The projects I work on have pdfs that need to be opened in groups.

So the automator would ideally perform all of this:

Desktop 1: pdf0 opened, maximized.
Create desktop 2, pdf1 opened and maximized to the left, pdf2 opened and maximized to the right.
etc...

The automator I have set up would work perfectly, except the bolded sections don't work as they should. Instead, pdf1 is opened and pushed to the left, then pdf2 is opened just fine, but the pdf1 is the one still "selected" and so pdf1 pushed from being maximized on the left to be maximized on the right... pdf2 still sits in the middle of nowhere, where it originally opened.

Is there anyway I can fix this?

Many thanks!
Nevermind, solved! Just added an applescript for switching windows using the shortcut "backtick"+command