A macro for PDF files with similar functionality as the "Open in" of iOS?

I use 4 different PDF readers on my Mac for different reasons:

  1. Mendeley Desktop as a reference manager
  2. Highlights for highlighting the PDF and exporting to markdown
  3. Skim and Preview for general reading

I have created a macro that can easily open the curently open PDF file (in the front application)
in another one of my PDF readers.
For example, I am reading a PDF in Skim and I will like to open it in Highlights without having to go to the location of the PDF in finder and right-click, "Open with".

Firstly, if macro groups control when a macro is active, so you almost certainly want the macro to be in a macro group that is active in those four applications, rather than an If that test that you are in one of those four apps, since its not at all clear what it would do if you were in some other app.

Then there are three problems, two easy ones and a hard one.

The process is basically:

  1. Get the path of the front document window in the current application.
  • Ask which app you want to open it in.
  • Open that path
  • in the target application.

The first step is by far the hardest. There is no set way to get the path of the front document. However @ComplexPoint posted a plugin action that should work for most applications (requires 10.10).

The second step is the Prompt For User Input as you have shown.

The third step then just uses %Variable%Path% in the Open File or Folder action (where “Path” is the name of the variable you set in the first step.

And the fourth step requires you to test the result of the second step and execute a different Open action for each one:

If Result Button is Skim
    Open %Variable%Path% with application Skim
If Result Button is Mendeley
    Open %Variable%Path% with application Mendeley
etc

Thanks.

Thank you a lot.

I would like to use this Macro for the same setup - Mendeley with Highlights - but I can’t work out how to reproduce it from the screenshot. Could you share your Macro?

Open in Application Macros.kmmacros (9.9 KB)

Hey Graham,

My macro group is quite different than Mirizzi's.

It uses Keyboard Maestro's conflict palette to produce a palette like this:

The front document in the frontmost application is opened in the desired application by pressing the character corresponding to that app in the palette.

Each macro looks like this:

So it's really simple to add more applications to the group.

Each macro must have the same keyboard shortcut in order to appear in the conflict palette – currently the keyboard shortcut is:

O

The first action in each macro calls a helper-macro to discover if the front application's front window has an associated document on disk.

If such a document exists then it can be opened in the desired application by pressing the associated keystroke (currently “p” and “s”).

I have NOT built any intelligence into the macros to prevent applications from opening files they shouldn't – this is an exercise for the reader/downloader. (In general conflicting file-types should just fail to open, but I haven't tested every possible combination.)

This macro could be adjusted to ALSO open files selected in the Finder, but I'm not going to bother unless there's enough interest.

-Chris