Help sending Esc keystroke to Vivaldi/Chrome

Hi all! I have been browsing around the forums trying to dig up a solution for a macro I'm working on but haven't found anything conclusive, so I'm hoping someone much more knowledgable about KM might have some insight. I am trying to create a macro that triggers when the Vivaldi browser window switches to a Google Docs tab and automatically sends the Escape keystroke, which should focus the document text. (This is to work around a Vivaldi bug whereby docs loses focus every time it's switched to from another tab.)

Everything seems to be working fine for recognizing the tab switch--I can trigger some display text successfully--but either the keystroke isn't sending or it's not performing its expected action. I tried using Cmd-W as the keystroke instead and that did work, closing the tab, but that's an application-level shortcut rather than a Google docs page shortcut, which might make the difference.

I've tried this both with Vivaldi on macOS Catalina (a new installation of KM 9) and with Chrome on Sierra with the same results, so it doesn't seem to be an issue specific to new Catalina security/accessibility settings. I'm hoping I'm just missing something obvious that you can point out to me! :slight_smile: Here's what I have:


(This is in an enabled macro set for Chrome/Vivaldi.)

Any suggestions? Or any way to tell that the keystroke is sending or where it's being captured? If I perform the action manually on either setup, pressing the Escape key after switching the tab correctly moves the focus into the document text, so the initial focus after switching tabs shouldn't be the problem.

Thanks for any help!

It might be a timing issue. Add a Pause of about 0.5 seconds BEFORE the Type Esc Action.

If the window has lost focus, then the ESC key will not go to the window.
Maybe try an Activate a Specific Application action at the top of your actions.

In the future, please upload both the Macro file and image. See How to upload your macro .

Good luck, and let us know how it goes.

Thank you! Pausing it the 0.5 seconds did it.

Focus Google Doc Text Macro (v9.0.4)
Focus Google Doc Text.kmmacros (4.3 KB)

I was unclear in the description. The Vivaldi browser and the tab still have focus, but the focus within the tab is shifted out of the text on the page to elsewhere. So sending the keystroke manually at that point worked, and it just needed that extra pause for it to work from KM. Brilliant. I appreciate the help (and the link for uploading the macro)!

1 Like