Different actions if text is selected or not?

Dear everyone,

Can you please help me with a simple if/then action?
I’m not sure how to chose different actions depending if I have text selected or not.

For example,
If text is selected, I want to cut it to clipboard and Insert Text by Typing "some text was selected"
and if nothing is selected, I want to Insert Text by Typing “nothing was selected”

Many thanks,
Sergey.

That depends on a lot of things.

If the application supports AppleScripting, there may be a way to do it through AppleScript.

If not, the best you can do is check to see if “Edit->Copy” is enabled, but not all apps disable that when text isn’t selected.

What application are you working with?

1 Like

I’m using ExtendScript Toolkit, it’s a JS IDE for Adobe products.

You’re right, it disables cut/copy menu command if nothing is selected, so I used trigger ‘A menu item with this name: Copy is enabled’ and it worked like a charm! Thanks for your help!

1 Like

A search I just did turned up a technique that @peternlewis posted some time ago. I didn't know about it, but have been using the same technique with great success for a long while:

Here's a macro I wrote based on suggestions and help from many others:

1 Like