Making space be send in 7 out of 8 game windows

Ask gaming related questions (AHK v1.1 and older)
Gentlemon
Posts: 3
Joined: 08 Jun 2021, 07:16

Making space be send in 7 out of 8 game windows

08 Jun 2021, 07:25

Hello.
Im trying to make a script to a game that will send a spacebar in 7 out of 8 game windows when turned on. Unfortunetly im not good enough to do it, and i can only do it in 1 window. I looked through forum and i did somethin like this:

Code: Select all

#NoEnv
SendMode Input
SetWorkingDir %A_ScriptDir%
#SingleInstance Force
 
Numpad1::
WinGet, hwnd1, ID, A
return
 
Numpad2::
WinGet, hwnd2, ID, A
return
 
F5::
loop
ControlSend, , {Space}, % "ahk_id " hwnd1
sleep, 2000

F6::
loop
ControlSend, , {Space}, % "ahk_id " hwnd2
sleep, 2000
[Mod edit: [code][/code] tags added.]

Only 1 character out of 2 (for now) is looping space when i turn it on. How can i make 7 characters do it?

If it helps it is to Turn based RPG game where when you press space you skip turn, and passing through 8 separate windows is just annying.

Ty for all help :). Have a good day!
User avatar
mikeyww
Posts: 26979
Joined: 09 Sep 2014, 18:38

Re: Making space be send in 7 out of 8 game windows

08 Jun 2021, 07:40

Code: Select all

win := []

F3::
win[WinActive("A")] := "{Space}"
SoundBeep, 1500
Return

F5::
For hwnd, key in win
 ControlSend,, %key%, ahk_id %hwnd%
Return
Gentlemon
Posts: 3
Joined: 08 Jun 2021, 07:16

Re: Making space be send in 7 out of 8 game windows

08 Jun 2021, 08:10

Ty for fast reply!

I can't get it to work. Sorry. Im new to scripts. Know about it from like 2 days or so. Can only make simple ones(for me) to work. But this one makes my head hurts.

Sorry for probs! Have a nice day
User avatar
mikeyww
Posts: 26979
Joined: 09 Sep 2014, 18:38

Re: Making space be send in 7 out of 8 game windows

08 Jun 2021, 08:54

If you press F3, it will store the HWND of the active window in an array. If you later press F5, it will send the Space to that window and any other "saved" windows (with their HWND stored). You can test it using two Notepad windows. The following demo will display a message box before each send.

Code: Select all

win := []

F3::
win[WinActive("A")] := "{Space}"
SoundBeep, 1500
Return

F5::
For hwnd, key in win {
 MsgBox, 0, HWND = %hwnd%, Sending: %key%
 ControlSend,, %key%, ahk_id %hwnd%
}
Return
Gentlemon
Posts: 3
Joined: 08 Jun 2021, 07:16

Re: Making space be send in 7 out of 8 game windows

08 Jun 2021, 09:09

Thanks for help. It works :). Have a good day!

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 56 guests