World of Warcraft pixelsearch - Slow script help Topic is solved

Ask gaming related questions (AHK v1.1 and older)
Detrim2
Posts: 8
Joined: 22 Jun 2017, 10:58

World of Warcraft pixelsearch - Slow script help

02 Dec 2017, 12:59

I'm a complete beginner when it comes to this stuff. The script works but it takes about 300 ms to run in World of Warcraft when I hit E. It's supposed to run down the list of pixelsearches (from most important to least important) until it finds one without error, sends that Numpad, and then returns waiting for me to press E again. That way one keystroke results in one action in-game.

Are there just too many pixelsearches happening, maybe pixelsearch is the wrong thing for this, or did I write this so badly that it's really inefficient? Any help is appreciated. :)

Computer specs:
WoW home and world latency at 25
Windows 10 Home 64 bit
i5 4690k
8 gig ddr4 memory
R9 280x video card

Code: Select all

#IfWinActive, World of Warcraft
#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
CoordMode, Pixel, Window

$E::

PixelSearch, FoundX, FoundY, 465, 904, 465, 904, 0x181410, 0, Fast RGB
If ErrorLevel = 0
{

	Send, e
	Return
}

PixelSearch, FoundX, FoundY, 19, 978, 19, 978, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {Numpad1}
	Return
}

PixelSearch, FoundX, FoundY, 61, 979, 61, 979, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {Numpad3}
	Return
}

PixelSearch, FoundX, FoundY, 79, 980, 79, 980, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {Numpad4}
	Return
}

PixelSearch, FoundX, FoundY, 100, 980, 100, 980, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {Numpad5}
	Return
}

PixelSearch, FoundX, FoundY, 19, 1000, 19, 1000, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {Numpad6}
	Return
}

PixelSearch, FoundX, FoundY, 82, 1000, 82, 1000, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {Numpad9}
	Return
}

PixelSearch, FoundX, FoundY, 101, 998, 101, 998, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {Numpad0}
	Return
}

PixelSearch, FoundX, FoundY, 19, 1020, 19, 1020, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {F1}
	Return
}

PixelSearch, FoundX, FoundY, 60, 1021, 60, 1021, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {F2}
	Return
}

PixelSearch, FoundX, FoundY, 81, 1020, 81, 1020, 0x02066A, 0, Fast RGB
If ErrorLevel = 0
{
	Send, {F3}
	Return
}

Return
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: World of Warcraft pixelsearch - Slow script help

02 Dec 2017, 19:32

Fast scans the screen horizontally it may work faster without the Fast option to scan vertically.Reference: PixelSearch
If you can use PixelGetColor it would be faster.
Detrim2
Posts: 8
Joined: 22 Jun 2017, 10:58

Re: World of Warcraft pixelsearch - Slow script help

02 Dec 2017, 20:39

Thank you for the reply. :) I first tried it without fast and it stayed the same. I then rewrote it to use PixelGetColor and it got a good amount faster. Went from 300ms delay to about 150ms delay. Unfortunately not as fast as just pressing the actual key for a skill in WoW which is instant.

This is what the script looks like now. Any other way to improve it? Really appreciate the help regardless. :)

Code: Select all

#IfWinActive, World of Warcraft
#NoEnv
SetWorkingDir %A_ScriptDir%
SendMode Input
CoordMode, Pixel, Window

$e::

PixelGetColor, color, 465, 904, RGB
If color = 0x181410
{
	Send, e
	Return
}

PixelGetColor, color, 19, 978, RGB
If color = 0x02066A
{
	Send, {Numpad1}
	Return
}

PixelGetColor, color, 61, 979, RGB
If color = 0x02066A
{
	Send, {Numpad3}
	Return
}

PixelGetColor, color, 79, 980, RGB
If color = 0x02066A
{
	Send, {Numpad4}
	Return
}

PixelGetColor, color, 100, 980, RGB
If color = 0x02066A
{
	Send, {Numpad5}
	Return
}

PixelGetColor, color, 19, 1000, RGB
If color = 0x02066A
{
	Send, {Numpad6}
	Return
}

PixelGetColor, color, 82, 1000, RGB
If color = 0x02066A
{
	Send, {Numpad9}
	Return
}

PixelGetColor, color, 101, 998, RGB
If color = 0x02066A

{
	Send, {Numpad0}
	Return
}

PixelGetColor, color, 19, 1020, RGB
If color = 0x02066A
{
	Send, {F1}
	Return
}

PixelGetColor, color, 60, 1021, RGB
If color = 0x02066A

{
	Send, {F2}
	Return
}

PixelGetColor, color, 81, 1020, RGB
If color = 0x02066A

{
	Send, {F3}
	Return
}

Return
User avatar
Xtra
Posts: 2750
Joined: 02 Oct 2015, 12:15

Re: World of Warcraft pixelsearch - Slow script help  Topic is solved

03 Dec 2017, 04:51

Try adding:

Code: Select all

SetBatchLines, -1
to the top of the script. That should help some.


To shorten the code you could use arrays for the values and then use one loop.
Example:

Code: Select all

#IfWinActive, World of Warcraft
#NoEnv
SetBatchLines, -1
SetWorkingDir %A_ScriptDir%
SendMode Input
CoordMode, Pixel, Window

posX := [465,19,61,79,100,19,82,101,19,60,81]
posY := [904,978,979,980,980,1000,1000,998,1020,1021,1020]
clr := ["0x181410","0x02066A","0x02066A","0x02066A","0x02066A","0x02066A","0x02066A","0x02066A","0x02066A","0x02066A","0x02066A"]
char := ["e","{Numpad1}","{Numpad3}","{Numpad4}","{Numpad5}","{Numpad6}","{Numpad9}","{Numpad0}","{F1}","{F2}","{F3}"]

$e::
    Loop 11
	{
		PixelGetColor, color, posX[A_Index], posY[A_Index], RGB
	    if (color = clr[A_Index])
		{
		    Send % char[A_Index]
			break
		}
    }
return
Detrim2
Posts: 8
Joined: 22 Jun 2017, 10:58

Re: World of Warcraft pixelsearch - Slow script help

03 Dec 2017, 11:57

Arrays! I think I'm in love. It's so much faster and cleaner looking now, practically instant. Thank you so much.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 125 guests