Script sending to two windows with the same name

Ask gaming related questions
dthomas0499
Posts: 1
Joined: 23 Jul 2020, 20:44

Script sending to two windows with the same name

23 Jul 2020, 20:48

I am having an issue where my script is sending the keys to both windows I have open that happen to have the same name. One of them are a window I am playing on and the other is one that I want the script to run on. How do I make it so it only runs on a specific window?

Code: Select all

#IfWinActive, World of Warcraft
Loop  
{
	ControlSend,,{w down},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,{w up},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,6,World of Warcraft	
	RandomSleep(10000,40000)
	ControlSend,,{a down},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,{a up},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,{d down},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,{d up},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,{s down},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,{s up},World of Warcraft	
	RandomSleep(2000,5000)
	ControlSend,,{z down},World of Warcraft	
	RandomSleep(1000,1500)
	ControlSend,,{z up},World of Warcraft	
	RandomSleep(1000,1500)
}
return

RandomSleep(min,max)
{
Random, random, %min%, %max%
Sleep %random%
}
Last edited by BoBo on 24 Jul 2020, 01:45, edited 1 time in total.
Reason: Moved to Gaming section. Added [code]/code]-tags.
User avatar
boiler
Posts: 6198
Joined: 21 Dec 2014, 02:44

Re: Script sending to two windows with the same name

23 Jul 2020, 22:32

Use the Window Spy tool to see if they each have a different ahk_class or something. If not, then you can get the unique ID (HWND) of each and then decide which one is the one to target and use that. You should be able to determine which one to target by its size and/or position.
Pepineros
Posts: 29
Joined: 16 Apr 2018, 17:26
Location: Ireland

Re: Script sending to two windows with the same name

25 Jul 2020, 00:56

Presumably you're only running this script while playing, right? In that case you don't need to use #ifwinactive.

Can you try the following (untested, sorry), run this script _after_ you run both instances of WoW:

Loop
{
ControlSend,,{w down},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,{w up},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,6,World of Warcraft,,A
RandomSleep(10000,40000)
ControlSend,,{a down},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,{a up},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,{d down},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,{d up},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,{s down},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,{s up},World of Warcraft,,A
RandomSleep(2000,5000)
ControlSend,,{z down},World of Warcraft,,A
RandomSleep(1000,1500)
ControlSend,,{z up},World of Warcraft,,A
RandomSleep(1000,1500)
}
return

RandomSleep(min,max)
{
Random, random, %min%, %max%
Sleep %random%
}


If this hack doesn't work, your best bet will be to get the PIDs or HWNDs of both windows and using that in your controlsends instead.

Let me know

Return to “Gaming”

Who is online

Users browsing this forum: Bing [Bot] and 10 guests