I'm looking for a .ahk that would send for example the key 4 to eight .exe windows when I press 4 on the first one... It is for a game called Dark Age of Camelot. If anyone could help me that would be great
![Smile :)](./images/smilies/icon_e_smile.gif)
Thank you,
Code: Select all
winTitle = ahk_exe notepad.exe
#If hWnd := WinActive(winTitle)
~4::
WinGet, win, List, %winTitle%
Loop, %win% {
If (win%A_Index% = hWnd)
Continue
WinActivate, % "ahk_id " win%A_Index%
Send 4 ; Alternative may be ControlSend
}
Return
#If
mikeyww wrote: ↑18 Jan 2022, 06:03What are the programs of the other windows?
An example is below.
Code: Select all
winTitle = ahk_exe notepad.exe #If hWnd := WinActive(winTitle) ~4:: WinGet, win, List, %winTitle% Loop, %win% { If (win%A_Index% = hWnd) Continue WinActivate, % "ahk_id " win%A_Index% Send 4 ; Alternative may be ControlSend } Return #If
It does work thank you so much however there is one thing, it changes clients and presses the number 4, is there a way to control only one client (the main character) and have 7 other just press the key 4 without ever switching to them?
Code: Select all
winTitle = Dark Age of Camelot
#If hWnd := WinActive(winTitle)
~4::
WinGet, win, List, %winTitle%
Loop, %win%
If (win%A_Index% != hWnd)
ControlSend,, 4, % "ahk_id " win%A_Index%
Return
#If
mikeyww wrote: ↑18 Jan 2022, 13:06Some windows will not respond to ControlSend, but you can try it.
Other tips sometimes needed: https://autohotkey.com/board/topic/111737-how-to-make-ahk-work-in-most-games-the-basics/Code: Select all
winTitle = Dark Age of Camelot #If hWnd := WinActive(winTitle) ~4:: WinGet, win, List, %winTitle% Loop, %win% If (win%A_Index% != hWnd) ControlSend,, 4, % "ahk_id " win%A_Index% Return #If
The value of SetKeyDelay determines the speed at which keys are sent. If the target window does not receive the keystrokes reliably, try increasing the press duration via the second parameter of SetKeyDelay
If this parameter is ahk_parent, the keystrokes will be sent directly to the target window instead of one of its controls