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.
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?
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.
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.