Found out that a single ControlSend does not work in such cases but here I found the following v1 script: "This is the seamless way to do it in Chrome and Edge and presumably other Chromium browsers; it doesn't change focus or the active window. I've been using this for years to send Win+Alt+x combinations to YouTube TV running in inactive windows."
(Note that I chancged "YTTVWinTitle" for my case to "ahk_exe brave.exe" since I just want to send the hotkey to "any" Brave instance, knowing the Ctrl-1 hotkey works in all tabs)
Code: Select all
ControlGet, ctrlID, Hwnd, , Chrome_RenderWidgetHostHWND1, ahk_exe brave.exe
if (ctrlID)
{
ControlFocus, , ahk_id %ctrlID%
ControlSend, Chrome_RenderWidgetHostHWND1, ^{1}, ahk_exe brave.exe
}
Can somebody help fixing this? I have seen that in v2 ControFocus needs the "Control" parameter, apparently this changed from v1?
Maybe a better solution works for v2, only boundary condition I have is -> it should not change focus of the active window...
Code: Select all
ctrlID := ControlGetHwnd("Chrome_RenderWidgetHostHWND1", "ahk_exe brave.exe")
if (ctrlID)
{
ControlFocus(, "ahk_id " ctrlID)
ControlSend("^{1}", "Chrome_RenderWidgetHostHWND1", "ahk_exe brave.exe")
}