Adding an image from a NamedClipboard into an alert

In an alert I want to show an image that is stored in a clipboard.

I am looking for something like

%DisplayAsImage%NamedClipboard%myClip%

Any work around or existing functions?

Alert actions are text fields, so you won't be able to insert an image. I'm not aware of any Keyboard Maestro action that can just display an image. You can put one on the clipboard then display the clipboard, or you could open it in Preview ... but if there's a native way to just display an image file, I don't know what it is.

-rob.

You could write the Named Clipboard to a temporary file as a PNG, use sips to convert that to an .icns file (may also need to resize -- the PNG must be square and its dimensions multiples of 256), the use AppleScript to throw a display dialog... with icon <path_to_icns_file>...

Which seems like a lot work...

@JimmyOnTheIsland -- do you want an actual Alert (which pauses the macro and gives the user a choice of stopping or continuing) or is this for some other purpose?

1 Like

If you write this macro, you will be required to name it The Rube Goldberg Solution.

Very creative, @Nige_S!

-rob.

1 Like

Could Custom HTML Prompt be used? (See, however, the limitation that is discussed in the topic Custom HTML Prompt refuses to load a local image).

Potentially you could try a shell script with the command qlmanage -p pathtothefile to invoke Quicklook for the image. But I don't know if the current clipboard has a path (or a path that is user accessible)? Just my first thought. Oh a named clipboard, that might be within reach, but I don't have time to check just now. Still something to consider perhaps.

Your wish, etc, etc...

After putting a screen grab of the Noto Emoji "Bomb" from halfway down this page onto the Named Clipboard "MyIcon":

The Rube Goldberg Solution.kmmacros (3.3 KB)

...results in:

Buttons can be tweaked, the script set to return the button pressed, and the macro can branch according to the result...

6 Likes

That's amazing. Its would be even nicer if an image could be added to KM's Display Progress Bar action. Do you have more rabbits up your sleeve (or aces in your hat) that might solve that?

You can't (again, AFAIK) change the KM "Progress" action's icon, and AS doesn't have a progress dialog.

I'd reach for swiftDialog. It has a progress bar option amongst all its other goodness, the downside being that it is something that needs installing before use. But that's trivial for your own Mac(s), and if you are managing a bunch of other people's computers you've probably installed it as part of your management process -- the dialogs are too useful to not do so.

Hello Folks :wave:

Why not trying to script the Alert or Prompt for User Input Action ?!

The TextField is Base64 encoded like the Comment Action - so I would try to prepare the Image to fit in and convert it to Base64 string and put the string into that field at runtime with AppleScript or JXA.

Maybe this will work. But I don’t have a guarantee it will. I’ve never tried or seen anything like this.

Greetings from Germany :de:

Tobias

Yes a pause macro solution. I want to have human confirm that the captured image was correct before further processing.

If a standard dialog icon is big enough you can use the AppleScript dialog, as above.

If (as I suspect) you need something bigger then a KM "Custom HTML Prompt", as suggested by @kevinb, is probably the way to go.

You might get away with using the "Display Named Clipboard" action, followed by a "blocking" alert and then an AS to close the window:

...but it's probably better to have everything as a single object such as a Custom HTML Prompt.

1 Like