Dynamic tag palette?

I’m using a collaboration website that supports hashtags. However, they do not yet have a pop-up to keep track of your tags, so I have to make sure my spelling is perfect on every tag.

I’d like to type the tag in the text field in Safari, highlight it, and fire a KM macro that would copy the text into a floating palette. Later, I could put the insertion point in the text field in Safari, click the tag(s) in the palette, and KM would paste the text into the field.

Is that even possible? How would I do it?

Thanks.

Definitely possible.

Instead of a KM pallette, I would use a KM Prompt for User Input to provide the choices.

Here are the pseudo Actions to accomplish this:

  1. Set the clipboard to "[NONE]"
  2. Type a keystroke "⌘C"
  3. IF Clipboard is Not "[NONE]" THEN
    • Set Variable DND__TagList to DND__TagList & "|" & Clipboard
      (the "|" symbol is used to separate choices in the Prompt list)
      ELSE
  • Prompt for User Input
    • Enter Variable myTag
    • Default value: |%DND__TagList%
      (We need to enter a "|" first to enable the use of a variable that contains choices)
  • User selects desired tag & clicks "OK"
  • Paste myTag
    END

I've obviously left out some details, but the basic logic should work.
"DND__" is the prefix I use for "Do Not Delete", so I'll know not the delete this variable when I'm doing cleanup.

I could write the macro for you, but, to be honest, you will learn more by doing it yourself. Give it a shot. If you have questions, or get stuck, feel free to reply.

Is there a way to make the taglist persistent? Can I save/load it to a text file?

All KM Variables are persistent, even across restarts of your Mac, so they generally don't need to be saved to a file.
If you open KM Preferences from the KM Editor, go to the Variables tab, and you will see all of the variables that have been created in your macros.

I love this app.

4 Likes

Couldn’t get it to work.

Could you please cobble together a basic version? I’ll learn more by looking at how you made it work right than staggering down a lot of blind alleys. Thanks.

Show me what you have got so far, and I'll give you some pointers.

Just click on your macro name in the macro column, goto Edit > Copy > Copy as Image.

If you are using Chrome, then just paste into your reply here.

If using Safari, then

  • Open Mac Preview app, and goto File > New from Clipboard, and save.
  • In your reply here, click on the upload button in the Editor toolbar, and choose your image.

Here it is. BTW, I'm on Safari, and I copied image to clipboard, pasted into Skitch and dragged into Discourse.

1 Like

Excellent!

The only thing wrong is this SET Variable, and I misled you on this:

%Variable%DND__TagList|%CurrentClipboard%

In a KM Text field, everything is explicit text, except for tokens, like variables and the clipboard:
%Variable%DND__TagList%

So you don't need the "&" operator that I am so used to using in AppleScript. :smile:

At the end of your macro, but inside of the IF/THEN Action, all you need is a Insert Text by Pasting "myTag".

See if that works, and if not, post more questions.

Oh, one more thing:

After the “⌘C” action, you might add a “Pause” action of about 0.2 sec.

No joy It doesn't seem to be even copying to the clipboard.

Did you make a selection BEFORE running the macro?

View the Clipboard History Switcher to see what is on the clipboard.

Does the prompt appear, asking you to pick a tag?

If you can't get it to work, then please upload the actual macro so I can test.
How to Post/Upload Your Macro to the Forum

Also, you might checkout this example I just posted. It is a general example of your use case, but does NOT include the COPY part:

Interesting. There seems to be something goofy going on with the SaaS web page. I can copy a word using Cmd-C or the Copy menu, but if I fire either of them from KM, it copies the URL of the page, instead of the highlighted word.

Any thoughts?

Can you give me a URL to test?

You are using CTRL-C as your KM trigger. That might conflict with the web page. Pick something else for the trigger hot key, like CTRL-SHIFT-C

I tried making a separate macro to fire off Cmd-C using Shift-Cmd-K as a trigger. It copies the URL. If I do Cmd-C on the keyboard, it copies the highlighted text on the page. Did the same thing with Edit>Copy.

IOW, I get a different result depending on whether I execute Cmd-C from the keyboard, or using a KM macro.

URL please.

I would use the technique in Create Text Expansion From Selection Macro. Just use slightly different XML for the macro, instead of having the Typed String trigger, just put the macro in your palette macro group and it will immediately appear in the palette.

So in summary:

  • Macro Group configured as displaying a macro palette (in Safari or whatever).
  • Variant of the Create Text Expansion From Selection Macro action that creates a macro in the above macro group, no trigger required. This macro could be triggered any way you like, and could even live in the macro palette group as well.

Some thoughts:

  1. Could you try using the Chrome Browser?
  2. See Safari Actions Not Working
  3. Instead of ⌘C, try the COPY Action and/or the Select Menu Item "Edit" , "Copy"