How to check that a variable does not contain an image

I have this macro:

Explain selected text (or open ChatGPT Explain).kmmacros (31.2 KB)

It checks whether I have something selected or not when I run the macro.

However in Preview app, cmd+c will add image of page to clipboard :expressionless:

So I need to make it so that macro still runs if there is image copied but how can I check that?

Is the image that it saves, basically clipboard contains an image, i need to add a condition here:

Thanks :black_heart:

It's very easy to check if the clipboard contains an image or not, using a Case statement or an If-Then; here are both examples:

You can also check for does not have text, has an image, and does not have image, so using one of those options, you should be able to make your macro do what you'd like it to do. (If it has an image, delete it until it's text? I'm not sure how you want to handle the image case, but you'll do it through either the Case or If-Then statements.)

-rob.

I can't see has text here

image

As I wrote above, "It's very easy to check if the clipboard contains an image or not…"

Use the checks I posted on the clipboard before you set the variable. Then set the variable according to the result of your test.

-rob.

ok yea this works, thanks

One bit of advice. Nested If Then Actions can make Macros difficult to read and debug. In this case you could just have both conditions in a single If Then:

1 Like