MACRO: A simple pop-up image viewer

In my pre-Tahoe system, I had a macro that used Quick Look and qlmanage to pop-up various images onscreen, without activating another app. As one example, I keep cheat sheets in PNGs to help me remember various things, such as which keys I've assigned to various Keyboard Maestro macros:

With a recent forced upgrade to Tahoe (a longer story), I can no longer use qlmanage outside of a true Terminal session (hooray, security?). So I wrote this simple replacement which uses a custom HTML prompt to display the chosen image, and a bit of Javascript to handle dismissing the window.

Image Viewer Macros.kmmacros (7.7 KB)

To use it, just enter the path to an image file in the green box in the Show image in pop-up macro. Run the macro, and that image should pop up onscreen.

I created it as a calling macro with subroutine, because I use it for a number of images.

This is quite basic, but I find it very useful, and it's much cleaner than the old qlmanage version was. Disclaimer: Claude wrote the JavaScript that manages the HTML window.

-rob.

4 Likes

How do you create these images?

Do you use a numpad as an extra input device?

What's the advantage to this (and your fixed version) compared to, say, loading the image to a Named Clipboard and using the "Display Clipboard" Action?

I make templates in Keynote, then export the slide as a PNG.

I use a desktop Mac with an external keyboard, and use keyboards with numeric keypads built in. My favorite the last few years has been Logitech's MX Keys S.

-rob.

One concern was memory usage: I believe named clipboards will always reside in Keyboard Maestro's RAM, correct? I have more than a handful of images I use like this, and I'd rather not have them all loaded into RAM all the time.

But the bigger issue is control over the display of the image. I just want to see the image itself with as little around it as possible. Even qlmanage had more window chrome than I wanted, but it worked so I never thought about the alternatives.

When it broke, I did look at using named clipboards, but even if I set the next engine window size to the exact image dimensions, there's still a surround, and a title bar showing Clipboard Entry that can't be removed.

-rob.

1 Like

Thank god, I feared there was a macro involved as well :grinning_face_with_smiling_eyes:

1 Like

RAM is becoming scarce! :upside_down_face:

I don’t know, but I would expect named clipboards not to be hanging around in RAM until they were needed, based on the description in the Wiki:

A Named Clipboard is not a true clipboard like the Mac’s System Clipboard. Rather it is simply a means to permanently store (like a file does) clipboard contents (like images or styled text) that can later be used to place on the System Clipboard.

Perhaps they would remain in RAM after use… but how hi-res are they? Well, anyway, it doesn’t matter, given your other considerations.

Named Clipboards are held in RAM. A rough guess of the size used can be gotten from the size of the Keyboard Maestro Clipboards.kmchunked file.

4 Likes

I was assuming you'd load the appropriate image to the Named Clipboard at execution, then display the Clipboard -- i.e. you'd only ever have one image loaded.

Minimising the window chrome and cruft -- that, I like!

2 Likes