"Insert text by typing", "Insert text by pasting" and window focus changes

I, sometimes, have seen my macros not working properly (i.e. the way it thought it would) while I was designing/testing them because, at some point, for a reason I could not explain focus changed.

One more exemple is this macro:

The general idea of this macro is to create a faster way to navigate from one specific tab to another specific tab of the frontmost Brave browser window.

As I often use pinned tabs (3 or 4), I always have 3 or 4 tabs I often want to go back to when I am on, for example, the 9th Brave frontmost opened tab.

On the 9th Brave frontmost opened tab, I press "Alt+Shift+)" so that a conflict palette opens. I select the name of the macro I want to select. Here "g - gmail.com - Tabs".

From that point,

  • I first make sure that the focus is still NOT on any anything that would make the macro not working properly. To do that, I emulate, with the F19 keystroke, a left mouse click a few pixels at the very left under the bookmark bar of my frontmost Brave browser window.

  • Then, I activate the Vimium Omnibar with the "B" keystroke. It launches some sort of a search bar so that I can filter through all the frontmost window opened tabs.

  • Here come what is important. In order to select then open the "mail.google.com" tab, I have to give Vimium enough information, so that it knows what tab it has to select. And then, open it.

I can do it by typing or pasting "mail.google.com" in the Vimium Omnibar.

From my afternoon tries, "Typing "mail.google.com"" in the Vimium Omnibar, even if I set a pause of 3 seconds after the pasting and before simulating the "Return" keystroke, activates the latest application. In other words, it makes your macro not working the way you want it to.

"Pasting "mail.google.com"" works like a charm. No latest application is activated.

Has anyone ever experienced the same? Is there a rationale behind those focus changes?