Macro for multiple window

Ask gaming related questions (AHK v1.1 and older)
allmightycola
Posts: 13
Joined: 30 Apr 2023, 20:17

Macro for multiple window

Post by allmightycola » 29 May 2023, 19:55

I want to be able to run a macro to 5 Windows. Here's an img of what i made and what im trying to achieve.
The problem i'm encountering is that whenever i start the macro on the first window then start it again on the 2nd window the first window stops.
https://imgur.com/QArUTSV

Code: Select all

; Generated by AutoGUI 2.5.8
#SingleInstance Force
#NoEnv
winTitle := "ahk_exe ArunafeltzRO.exe"
Global pid, sel1
Global pid, sel2
Global pid, sel3
Gui Add, DropDownList, x14 y52 w120        vsel1
Gui Add, DropDownList, x14 y125 w120       vsel2
Gui Add, DropDownList, x16 y196 w120       vsel3
Gui Add, DropDownList, x17 y267 w120       vsel4
Gui Add, DropDownList, x18 y338 w120       vsel5

Gui Font, cRed, Tahoma
Gui Color, 0x000000
Gui Add, Text, x12 y23 w120 h23 +0x200, Butete1
Gui Add, Text, x13 y93 w120 h23 +0x200, Butete 2
Gui Add, Text, x16 y165 w120 h23 +0x200, Butete 3
Gui Add, Text, x16 y238 w120 h23 +0x200, Butete 4
Gui Add, Text, x18 y307 w120 h23 +0x200, Butete 5

Gui, Add, Button, x142 y50 w54 h23 gR1, Run
Gui, Add, Button, x205 y50 w54 h23 gS1,Stop
Gui, Add, Button, x143 y125 w54 h23 gR2,  Run
Gui, Add, Button, x144 y194 w54 h23 gR3,  Run
Gui, Add, Button, x148 y266 w54 h23 gR4,  Run
Gui, Add, Button, x149 y338 w54 h23 gR5,  Run
Gui, Add, Button, x207 y124 w54 h23 gS2,  Stop
Gui, Add, Button, x209 y195 w54 h23 gS3,  Stop
Gui, Add, Button, x211 y266 w54 h23 gS4,  Stop
Gui, Add, Button, x216 y336 w54 h23 gS5,  Stop
Gui Show, w283 h391, Wave Mode V2

Gosub F3

F3:: ; F3 = Show the GUI
WinGet win, List, % winTitle
If win {
 windows := ""
 Loop % win {
  WinGetTitle title, % thisWinTitle := "ahk_id" win%A_Index%
  WinGet, pid, PID , % thisWinTitle
  windows .= "|" pid " " title
 }
 GuiControl, Enable, sel1
 GuiControl,, sel1, % windows
 GuiControl, Choose, sel1, 1
 GuiControl, Enable, Run

 GuiControl, Enable, sel2
 GuiControl,, sel2, % windows
 GuiControl, Choose, sel2, 1
 GuiControl, Enable, Run

 GuiControl, Enable, sel3
 GuiControl,, sel3, % windows
 GuiControl, Choose, sel3, 1
 GuiControl, Enable, Run


} Else {
 SoundBeep 1500
 GuiControl,, sel1, |
 GuiControl, Disable, sel1
 GuiControl, Disable, Stop

 SoundBeep 1500
 GuiControl,, sel2, |
 GuiControl, Disable, sel2
 GuiControl, Disable, Stop

 SoundBeep 1500
 GuiControl,, sel3, |
 GuiControl, Disable, sel3
 GuiControl, Disable, Stop
}
GuiControl, Focus, sel1
GuiControl, Focus, sel2
GuiControl, Focus, sel3


Return

R1:
Gui, Submit, NoHide
 pid := RegExReplace(sel1, " .+")
 SetTimer go1, 25
 SoundBeep 1500
return

S1:
Gui, Submit, NoHide
SetTimer go1, Off
SetTimer go, Off
SoundBeep 1000
return

R2:
Gui, Submit, NoHide
 pid := RegExReplace(sel2, " .+")
 SetTimer go, 25
 SoundBeep 1500
return

S2:
Gui, Submit, NoHide
SetTimer go, Off
SoundBeep 1000
return

R3:
Gui, Submit, NoHide
MsgBox, HELLO!
return

S3:
Gui, Submit, NoHide
MsgBox, HELLO!
return

R4:
Gui, Submit, NoHide
MsgBox, HELLO!
return

S4:
Gui, Submit, NoHide
MsgBox, HELLO!
return

R5:
Gui, Submit, NoHide
MsgBox, HELLO!
return

S5:
Gui, Submit, NoHide
MsgBox, HELLO!
return



GuiEscape:
GuiClose:
    ExitApp


 go() {
 ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f1}, % "ahk_pid" pid
sleep, 50
ControlSend,, {f1}, % "ahk_pid" pid
sleep, 50
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5},% "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f2}, % "ahk_pid" pid
sleep, 50
ControlSend,, {f2}, % "ahk_pid" pid
sleep, 50
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f3}, % "ahk_pid" pid
sleep, 50
ControlSend,, {f3}, % "ahk_pid" pid
sleep, 50
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {f4}, % "ahk_pid" pid
sleep, 50
ControlSend,, {f4}, % "ahk_pid" pid
sleep, 50
}
return

go1() {
 ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {1}, % "ahk_pid" pid
sleep, 50
ControlSend,, {1}, % "ahk_pid" pid
sleep, 50
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5},% "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {2}, % "ahk_pid" pid
sleep, 50
ControlSend,, {2}, % "ahk_pid" pid
sleep, 50
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {3}, % "ahk_pid" pid
sleep, 50
ControlSend,, {3}, % "ahk_pid" pid
sleep, 50
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {5}, % "ahk_pid" pid
sleep, 100
ControlSend,, {4}, % "ahk_pid" pid
sleep, 50
ControlSend,, {4}, % "ahk_pid" pid
sleep, 50
}

Return to “Gaming Help (v1)”