Save and Recall All Open Windows and Documents?

As a book and video course author, article writer, graphic designer, and self-employed business owner, I work on a lot of projects and common sets of tasks. I use KM to launch groups of applications and documents. For instance, when I’m finalizing a video course, I have KM launch 4 URLs in Chrome, 3 Word documents, 4 Finder paths, and a couple of miscellaneous things.

One click (the macro runs from an icon on the Dock) gets me everything I need for that workflow, but I have to configure the many steps of that one-click macro manually. I’m hoping to find a more automated solution of telling KM what I need opened for each workflow.

In the above example I have to create Open and Open URL actions for all those items, and then manually supply KM with the file and folder paths. These change for every course I create, which is 1-3 per month (the Chrome URLs are always the same), and I four total course-related launch macros (Recording, Editing, Finalizing, and Marketing), all with paths that change per project.

For the macros that launch workflows for articles I’m working on, those paths change even more frequently–up to 9 per month, often with 2-4 being worked on concurrently–which means copying a bunch of paths from Finder and pasting them into several macros in KM Editor. In the end, the macro configuration takes up more time and effort than I save by having KM batch launch everything for me rather than me opening each file, folder, and URL manually.

Here’s my question: Is there any way to get KM to save which applications, files, and Finder windows and tabs are open, and then reopen those en masse from a macro?

If there’s just no way to do it in KM, does anyone know of another method or utility that could save and recall at will all open windows and documents?

Hey Pariah,

Yes, but it’s not going to be a no-brainer task.

Run this in the Applescript Editor.app to see an AppleScript-List-Object showing tab-urls in sub-lists by window:

tell application "Google Chrome"
   set windowTabList to URL of tabs of windows
end tell

That list can be broken down into text OR it can be saved as is and used to rebuild a window/tab structure.

To do something similar in the Finder:

------------------------------------------------------------------------------
tell application "Finder"
   set winList to windows
   repeat with theWin in winList
      try -- Filter-out any search windows and convert to aliases.
         set contents of theWin to (target of theWin as alias)
      on error
         set contents of theWin to 0
      end try
   end repeat
end tell

# Finish filtering
set winList to aliases of winList
------------------------------------------------------------------------------

To get running application names:

------------------------------------------------------------------------------
tell application "System Events"
   set runningAppList to name of processes whose background only is false
end tell
------------------------------------------------------------------------------

This gives you most of the pieces you need to construct your macro.

Remember to TEST AppleScripts in the Script Editor.app, BEFORE trying to run them from Keyboard Maestro.

The scripts I’ve provided return AppleScript objects and don’t play as nicely with Keyboard Maestro as will ultimately be desired.

You’re going to have to decide how you want to store your data-sets, before you adjust the output of the scripts to suit.

-Chris

It's two years later.

Is there a more modern way to do this?

Specifically, I want to make a macro that will record all the open document windows of all the apps and be able to reopen them later. It would be fine if it recorded it to a text file and another macro opened it.

I just want a way to be able to reopen all the document windows I had open. Back in OS9 days there was a little app that did this, but not any more.

Thanks

Hey @anamorph,

There are a variety of apps that will store and restore window positions:

https://manytricks.com/moom/

https://cordlessdog.com/stay/

http://www.funk-isoft.com/display-maid.html

I'm not certain if any of them will launch applications and restore open files though.

You'll have to experiment.

-Chris