Copy with Selection Test [Sub-Macro]

2017-09-14 8:55 PM CT

Revised to use KM Copy Action with Clipboard Seed to determine if selection was made.

MACRO:   COPY with Selection Test [Sub-Macro]

~~~ VER: 2.0    2017-09-14 ~~~

DOWNLOAD:

COPY with Selection Test [Sub-Macro].kmmacros (6.3 KB)
Note: This Macro was uploaded in a DISABLED state. You must enable before it can be triggered.

ReleaseNotes

Author.@JMichaelTX

PURPOSE:

  • Attempt to Copy User's Selection
    • and set KM Variable to indicate IF Clipboard has changed.

HOW TO USE:

  1. Call this Sub-Macro in an Execute Macro Action
  2. Then use a IF/THEN Action to test for KM Variable "CBS__Clipboard_Changed"
    = 1 IF the Clipboard has changed

NOTE: This version uses the KM Copy Action (rather than using ⌘C)

  • It is faster if there is a selection (no pause needed)
  • Has a timeout of 2 seconds if there is no selection.

MACRO SETUP

  • No trigger is needed since it is called as a Sub-Macro
  • Place in Group with GLOBAL access
  • ENABLE this Macro.

TAGS: @SubMacro @Selection @Copy

USER SETTINGS:

  • There are no user settings.

REQUIRES:

  1. Keyboard Maestro Ver 7.3+ (don't even ask me about KM 6 support).
  2. El Capitan 10.11.6+
  • It make work with Yosemite, but I make no guarantees.

USE AT YOUR OWN RISK

  • While I have given this limited testing, and to the best of my knowledge will do no harm, I cannot guarantee it.
  • If you have any doubts or questions:
    • Ask first
    • Turn on the KM Debugger from the KM Status Menu, and step through the macro, making sure you understand what it is doing with each Action.

image

3 Likes

This is awesome, thanks.

Thanks, but I have since discovered a better method to determine when the Clipboard has changed.

Please see:

1 Like

Cool, I tested this and it works the same. Out of curiosity, how is it better?

It is better because it uses a direct method of detecting if the Clipboard has changed, without making a change itself to the Clipboard. I also like #2 because it does not use a sub-macro.

Both methods will work. I used method #1 a long time before I discovered method #2.

1 Like

Could you elaborate on this? I've tested both #1 (USE command-C with Short Pause) and #2 (copy with "Tiimeout Aborts Macro" unchecked and a short action timeout) but in both cases, running this macro does change my clipboard.

If you use this macro:
MACRO: [CB] How to Detect When Clipboard Has Changed [Example]

it does NOT change the Clipboard IF the user has NOT selected anything.

Ok cool, that could actually be useful. Just tested and it works!

Just updated my macro in my OP.