How to send key to 2 different inactive windows Topic is solved

Ask gaming related questions (AHK v1.1 and older)
kaos
Posts: 2
Joined: 26 Jul 2021, 17:55

How to send key to 2 different inactive windows

Post by kaos » 26 Jul 2021, 18:28

Hello guys
first off I am not a programmer^^' but I need help with a script.

I want to send a key to 2 different inactive windows every 3 seconds. I want it to pause when a window becomes active, and continue when both are inactive again.
this is my old code I have been messing with. For some reason it keeps sending g to the window2 eventho I have window1 active. O.o

pls help

Code: Select all

DetectHiddenWindows, On

wintitle = game title 1
wintitle2 = game title 2

#g::
Loop {
IfWinNotActive, %wintitle% && %wintitle2%
{
	controlsend,,g, %wintitle%,
	sleep, 50
	controlsend,,g, %wintitle2%,
	sleep, 2500
}
}
return
Rohwedder
Posts: 7511
Joined: 04 Jun 2014, 08:33
Location: Germany

Re: How to send key to 2 different inactive windows  Topic is solved

Post by Rohwedder » 27 Jul 2021, 00:36

Hallo,
try:

Code: Select all

DetectHiddenWindows, On
wintitle = game title 1
wintitle2 = game title 2
#g::SetTimer, Games, 2550
Games:
If !WinActive(wintitle) && !WinActive(wintitle2)
{
	controlsend,,g, %wintitle%,
	sleep, 50
	controlsend,,g, %wintitle2%,
}
Return
User avatar
mikeyww
Posts: 26437
Joined: 09 Sep 2014, 18:38

Re: How to send key to 2 different inactive windows

Post by mikeyww » 27 Jul 2021, 00:41

Another one:

Code: Select all

For each, app in win := ["game title 1", "game title 2"]
 GroupAdd, wins, %app%
#g::
Loop {
 SetTimer, Go, 3000
 SoundBeep, 1500
 WinWaitActive, ahk_group wins
 SetTimer, Go, Off
 SoundBeep, 1000
 WinWaitNotActive
}
Go:
For each, app in win {
 ControlSend,, g, %app%
 Sleep, 50
}
Return
kaos
Posts: 2
Joined: 26 Jul 2021, 17:55

Re: How to send key to 2 different inactive windows

Post by kaos » 01 Aug 2021, 11:48

Hey it works thank you sooooo much :D I was really grinding my head against this thank you!^^
Post Reply

Return to “Gaming Help (v1)”