Speed up a macro? (insert text by pasting + simulate keystroke)

Hi all! I have a macro that consists of two actions - one being "insert text by pasting" and one being "simulate keystroke." To be more specific, I have a ~40 character text string connected to the insert text action, and the return key connected to the keystroke simulation action. The macro is triggered by a hotkey.

What I'm wondering is how I can speed up the time it takes for the entire macro to complete. I've sat and tested it to where when I press the enter key myself the moment I see the text string appear in a text box, it'll be faster than if I were to wait for the macro to carry out the return keystroke simulation. There isn't an enormous delay (definitely shorter than 1 second) but this macro is being used for something where a quicker response time from the keystroke simulation would be very helpful. Inserting an action delay controller between them and messing around with the delay times doesn't seem to have much of an impact.

Any and all suggestions are warmly appreciated! Thanks again to all who have taken the time to read this.

If your macro is just:

  • Insert Text by Typing "Blah blah blah"
  • Type a Keystroke: Enter

There should be basically no perceptible delay in simulating that.

Thank you for the response Peter. I guess I wouldn't necessarily call it "delay", as the time in between the actions is less than half a second. But the fact that the sequence is carried out faster when I manually hit my enter key as soon as I see the pasted text enter the textbox makes me think there could be something I could do to speed it up.

Have you tried putting the RETURN in the "insert text by pasting" Action?

1 Like

That was one of my first thoughts but it was to my knowledge that there's no way to directly insert a key like that into the "insert text by pasting" function.

There is, and it can be done like this:

image

2 Likes

But if that improves things, then something is wrong with your setup (perhaps misuse of the Set Action Delay action).

Because there should be no practical difference between

  • Insert Text by Typing "Blah blah blah"
  • Type a Keystroke: Return

And

  • Insert Text by Typing "Blah blah blah%Variable%Return%"

In normal operation, these two should be within about 0.01 seconds of each other. Here is a not particularly scientific test, which shows even with extra stuff going on, the actions execute within between 0.06 and 0.07 seconds either way.

Blah blah blah
0.067468
Blah blah blah
0.066956

Blah blah blah
0.068913
Blah blah blah
0.061

Blah blah blah
0.068936
Blah blah blah
0.063079

Time Text Inserion.kmmacros (3.3 KB)

oldImageoldImage.png

For some reason that won't work for me. For example, if I run that in the address bar of a new tab on my browser, it will paste "Blah Blah Blah" and redact %Return%, but as far as I can tell the return key is not being simulated.

No, it wouldn't do in the example @gglick demonstrated, as the %return% token is a text token that inserts a carriage return character into the text string. It is not a keystroke simulator. But it wasn't clear up to this point that you specifically wanted an actionable keystroke and not simply just a new paragraph within your text.

What is it that you are actually trying to achieve ? Perhaps if we all are clear on what the ultimate goal is, we can brainstorm solutions that get you there. Sometimes, the path we're fixed on taking is not the only one, nor necessarily the best one.

I personally feel that any macro, script, or what-not that relies on keystrokes and delays and automated mouse clicks is almost always the choice best avoided; it's a last-ditch technique to use when all other avenues are demonstrably fruitless, and probably not even then.

But if you're able to share more specifics of what your end goal is, include the situations you'll be using your macro in too, i.e. a real use case. Describe whether the actions are taking place entirely inside one specific application (you mentioned the address bar of your web browser), and whether the text and keystroking is targeted at a specific text field; or whether it's intended to be universal, and operate in all applications and all text fields. Lastly, don't omit what you want the result of hitting ⟨RETURN⟩ to be: for example, if you were aiming to simulate the keystroke so that your browser would navigate to the address you entered in the bar (and leaving out the obvious other means of opening a URL), it's perfectly possible to action a text field like that as if one had pressed ⟨RETURN⟩, but without actually having to press it.

The rest of your post I heartily concur with, but I'm afraid you're mistaken about this. It absolutely can be a keystroke simulator when inserted via typing:

Insert Return via Typing

1 Like

Sorry, I made a small mistake in my original post; that should have been insert text via typing, not pasting. It should definitely work, as you can see in my post above, but as @peternlewis says and demonstrates, doing it this way shouldn't have a measurable effect on the macro's speed, which almost certainly means that some other factor is at work in the slowness you're experiencing.

Oh my golly! Egg on my face for not trying it out first. I am pleasantly surprised by this. Thanks!

1 Like

Interesting! My only issue here is this would sort of defeat the whole purpose of this as I need it to be fast, and the fastest speed the macro can simulate typing would still be slower than the macro i'm working with currently.

Appreciate the response! I work from home (customer service live chat representative here!) The way it works is I click on an incoming chat to, and then I enter an introductory message in the newly-opened conversation's text box. Last step is to hit enter to send my message. That way I can ensure that the chat is in my inbox, and not available to be claimed by any other representatives. Having a hotkey to paste and send my introductory message makes this process more easy, efficient, and lucrative for me. During peak hours it can be difficult to claim enough chats, so the goal here is to slim down the speed of my macro as much as possible.