New AHK Script to send one input to multiple .exe
New AHK Script to send one input to multiple .exe
Hello,
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
Thank you,
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
Thank you,
Re: New AHK Script to send one input to multiple .exe
What are the programs of the other windows?
An example is below.
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
Re: New AHK Script to send one input to multiple .exe
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
Hello,
Here are two screenshots of the program in question, not sure which one you needed so I just sent both:
https://prnt.sc/26f8z0k
https://prnt.sc/26f8z7e
I'm noob at ahk would I just change the (winTitle) to the name of the program?
also do the windows have to be in windowed or is windowed fullscreen fine?
Thank you
Re: New AHK Script to send one input to multiple .exe
Yeah, I would just try it. Could use winTitle = Dark Age of Camelot at the top. See what happens.
Re: New AHK Script to send one input to multiple .exe
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?
Re: New AHK Script to send one input to multiple .exe
Some 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
Re: New AHK Script to send one input to multiple .exe
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
Does not work with the controlsend but I'll make due with the first one thank you very much!
Re: New AHK Script to send one input to multiple .exe
When using ControlSend you can try using SetKeyDelay at the top of your script.
SetKeyDelay, 50, 50
You can also try using ahk_parent:
ControlSend, ahk_parent, 4, % "ahk_id " win%A_Index%
SetKeyDelay, 50, 50
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
You can also try using ahk_parent:
ControlSend, ahk_parent, 4, % "ahk_id " win%A_Index%
If this parameter is ahk_parent, the keystrokes will be sent directly to the target window instead of one of its controls