Send a key to multiple windows of the same class Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Ecimeric
Posts: 130
Joined: 11 Jan 2017, 02:23

Send a key to multiple windows of the same class

Post by Ecimeric » 23 Jan 2022, 15:08

Code: Select all

if !WinExist("ahk_class Qt5QWindowIcon")
    return
else {
    ControlSend, ahk_parent, s, ahk_id %vlcid1%
    ControlSend, ahk_parent, s, ahk_id %vlcid2%
}
return
How can I send s to up to two VLC windows?

User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Send a key to multiple windows of the same class  Topic is solved

Post by boiler » 23 Jan 2022, 15:37

I'm not sure VLC reacts to ControlSend, as is the case with many applications' windows. This script will do it by activating each VLC window that is open and using Send. You can experiment with using ControlSend with the structure of this script for acting on all of the VLC window instances.

Code: Select all

WinGet, WinList, List, ahk_class Qt5QWindowIcon ahk_exe vlc.exe
loop, % WinList {
	WinActivate, % "ahk_id " WinList%A_Index%
	Send, s
}

Ecimeric
Posts: 130
Joined: 11 Jan 2017, 02:23

Re: Send a key to multiple windows of the same class

Post by Ecimeric » 23 Jan 2022, 16:05

Code: Select all

WinGet, WinList, List, ahk_class Qt5QWindowIcon ahk_exe vlc.exe
Loop, % WinList
    ControlSend, , s, % "ahk_id " WinList%A_Index%
Perfect, thank you! :D

Post Reply

Return to “Ask for Help (v1)”