Insert Text -- Not Expanding Tokens?

Hey there. Just trying this software out because Automator has failed me. And running into issues here as well.

Specifically everything seems to work EXCEPT for the "Insert Text" when I use any type of variable. I've tried using %SystemClipboard% ... I've tried taking a variable from the user. I've tried insert by Typing and insert by Pasting. All of them end up causing the same thing. The string that should be expanded, such as %SystemClipboard% or %Variable%code% ... Ends up being typed/pasted as that raw text, and not the value.

What's odd is that I tested these by adding an Alert with these in the text box instead, and there they are being expanded. So why aren't they being expanded in the 'Insert Text' options?

Howdy, welcome to the forum! As you might have already figured out, this is a great community full of people who love to help.

If possible, post the macro itself so we can take a look at it and see what might be going wrong. As one of the moderators likes to say, "If we're not testing we're guessing, and guessing often wastes people's valuable time". :laughing: If you need help on how to post the macro, just let us know and we can walk you through it.

If you haven’t had the opportunity to read this tutorial, I highly recommend it. It will help you get the most help for your question.

Tip: How Do I Get The Best Answer in the Shortest Time?

All that being said, typically when you want to insert the actual token/variable etc. using the insert text by pasting/typing action, you need to wrap them in double % symbols. So instead of %SystemClipboard% you would use %%SystemClipboard%%.

Try that out and see if it works for you.

-Chris

Post a sample macro that demonstrates the issue -- instructions for posting here. But do also check the "Insert..." action's Settings (click the cogwheel) and make sure that it isn't set to "Process nothing" and so not evaluating the tokens.

1 Like

Thanks @cdthomer ... But looks like @Nige_S 's comment was what I needed. The single % works fine, but the gear for insert Text was set to 'Process Nothing'.

Kinda odd I have to admit to have that still be the setting after using the 'Insert Token' dropdown to add a token. Meaning it does nothing.

Thanks friends

1 Like

IMO good design -- you've explicitly told the action to not process tokens, so KM shouldn't change things behind your back. You might, for example, want to display a list of variable names and be adding those variables with the "Insert Token" dropdown.

@Nige_S ... Fair point, except that I didn't explicitly told it to not process tokens. That was the default.

Worse (IMO, YMMV) that default appears to be different for different actions. If you insert an Alert, it defaults to process. If you instead a 'type text', it defaults to 'not process'.

And I'd wager that 95% of the time that when someone is inserting a token into 'type text' ... that they want it to be evaluated :slight_smile:

Not on my systems -- all actions default to "Process Text Normally" (you don't get the choice on "Alert" actions). Have you got these actions as "Favourites"? IIRC "Favourites" retain any options you've set, which could explain it.

No favorites. Just installed the app and started trying to use it.

However I'm guessing I know the difference I just realized. Because I originally made my macro by recording my actions. And then afterwards was going into it and updating the text to use tokens.

Appears that when it's during a recording, it sets those to 'process nothing' by default

2 Likes

This will need @peternlewis's attention. I rarely use recording, but if I do, I would expect the behavior to be consistent.

I did a test a found something interesting.
This is my steps:

  1. Click "Record"
  2. Hit ⌃⌘A to call up the Add action window.
  3. Type insert (insert is already in the search window, but I re-typed it for this test.)
  4. Hit Return.
  5. Click "Record" again to stop recording.

The result is as below:

As you can see, KM adds an Insert Text by Typing and an Insert Text by Pasting.

(Sometimes, the Type the Return Keystroke action comes after the Insert Text by Pasting action.)

The Insert Text by Typing has the Process Nothing setting, and the Insert Text by Pasting has the Process Text Normally setting.

The Insert Text by Pasting action is what I really intended and has the default setting as we expected as well.
I can't explain the Insert Text by Typing action as well as its setting.

Below is a gif, and @peternlewis might be able to answer why.

2022-11-15 16-12-07.2022-11-15 16_14_06

Great! Glad to hear he was able to provide the assistance you needed. I marked his response as the solution for reference.

Have a great day!

You often get strange effects when recording actions in the thing that's recording the actions! KM is recording what you've done -- you started recording, you hit ⌘⌃A, you typed "insert" into the search box, and you hit Return, all of which KM has faithfully added, then you stopped recording. And then the result of those actions, the "Insert Text by Pasting", is added because that's what you've just told KM to do.

2 Likes

The default for actions is almost universally Process Tokens.

When you record typed text, the text is recorded and played back. In that case, the Process Tokens is turned off explicitly. I can't imagine anyone would record typing "%LongDate%" and expect it to play back as a date.

The first three actions are entered as part of the recording. Hence, the Insert Text action has captured your typed text of “insert” and is configured to not process tokens.

The last action is the result of your adding the action. It is not recorded. Recording does not stop the things you are doing form happening. Recording while in the editor and changing your actions is going to produce interesting results.

The expectation of playing back a recording is that it plays back what you did, more or less, but as accurately as reasonably possible. That said, recordings typically need some level of cleanup unless they are straight typing. Recording also tries to capture the highest level intent (such as moving windows or selecting menus rather than just mouse clicks).

3 Likes