Why Does This "Type Slowly" Macro Finish "Too Quickly"?

I had a situation in automating a web page user where Insert text by typing seemed to be not doing anything for a date string such as "04/21/2023". So on a hunch I substituted this subroutine, and it works.

But as it contains a 1-second pause before typing each character, it should take, for an 8-character string, eight seconds, shouldn't it? But it takes roughly one second total, about the same time as, and the characters appear on screen about as rapidly as, Insert text by typing. Although using this macro solved my problem, I'm curious about the lack of delay.

Type slowly Macro (v10.2)

Type slowly.kmmacros (3.0 KB)

Not necessarily how I would do it but your regex .+ matches the whole string so that will be typed in one go.

Try changing the regex to . which matches one character only.

Whoops, I forgot the "non-greedy" qualifier, so my regex was getting the whole string in one swoop. I changed the regex to .+? and that makes it take ~8 seconds.

But I think I'll change it back, since it worked before!

My question then is really: why does the rapid (faulty, really, given the intent of the macro) Type slowly version work in this situation where Insert text by typing doesn't?

@tiffle, our initial replies "crossed in the mail." Thanks. Still have the followup question I just put in my previous reply, though.

Since you’re filling in a date field my guess is some validation is happening either in the browser or at the server, and that’s preventing it “keeping up” with typing that’s faster than a human can do.

Personally I’d use the action to slow up the typing speed. To use it, have a look at the KM wiki here; action:Set Action Delay [Keyboard Maestro Wiki]

My guess was the same, and motivated my creating this (faulty) macro. But the faulty but working(!) version appears to be using Insert Text by Typing on the entire string just as the plain old Insert Text by Typing action it replaced does. Yet the "plain old" action fails while this macro works.

The subroutine has a 1-sec delay before “blasting out” the date whereas your other approach doesn’t have that delay. I’ll bet that if you go back to your original version (which I haven’t seen BTW so I’m only guessing) but insert a 1 sec pause just before the typing action you’ll possibly get it working OK.

My reason for guessing this is to do with what happens prior to filling in the date field. If it involves mouse movement, or switching between fields, or bringing a window to the front, or activating a tab, etc. etc. then the 1 sec pause allows your Mac/browser/website to “catch up” and behave nicely.

Maybe.

Alas, I originally had a 1-sec pause before Insert Text by Typing. Sorry to make you guess. :slight_smile:

Oh well… if you really want to find the reason you’ll need to post your original macro and info re what website you’re working with.

Slight tangent, but how would you pause until any button exists? Tried this but no luck....

(Also tried .*)

@noisneil - try a button matching .+ (not at my Mac so can’t check for exactness).

Ah yes, of course. :man_facepalming:t2:

Thanks!