need help using imagesearch Topic is solved

Ask gaming related questions (AHK v1.1 and older)
joliter
Posts: 17
Joined: 13 Jun 2016, 21:49

need help using imagesearch

15 Jul 2017, 22:57

I'm trying to find items in my inventory in a game. The items seem the same to the human eye, no matter the space it's in the inventory. The problem is when you move the mouse on the item it starts to give off a glowing effect, and I'm not sure if that's why my image search sometimes doesn't work?
For example I took a screenshot of the item "DragonRuins" and made it the smallest pixel. It searches for the item in my inventory, Left Clicks it, then drops it on the ground, and clicks the button "yes I want to drop this".
Sometimes it doesn't find some of the items, and I don't understand if there is a better way to do this?

Thanks a lot

Code: Select all

Loop {
ImageSearch, FoundX, FoundY, 637, 487, 1000, 641, DragonRuins.png
If(ErrorLevel == 0){
	SendEvent {Click %foundX%, %foundY%}
	Sleep, 100
	SendEvent {Click 329, 394}
	break
}
}
ImageSearch, FoundX, FoundY, 415, 383, 610, 447, yes1.png
If(ErrorLevel == 0){
SendEvent {Click %foundX%, %foundY%}
}
neomulemi6
Posts: 216
Joined: 30 Jun 2016, 06:01

Re: need help using imagesearch  Topic is solved

16 Jul 2017, 19:06

You can try adding a variation to the ImageSearch. Should increase its dependability.

Change ImageSearch, FoundX, FoundY, 637, 487, 1000, 641, DragonRuins.png

to something like

ImageSearch, FoundX, FoundY, 637, 487, 1000, 641, *12 DragonRuins.png
joliter
Posts: 17
Joined: 13 Jun 2016, 21:49

Re: need help using imagesearch

17 Jul 2017, 18:04

neomulemi6 wrote:You can try adding a variation to the ImageSearch. Should increase its dependability.

Change ImageSearch, FoundX, FoundY, 637, 487, 1000, 641, DragonRuins.png

to something like

ImageSearch, FoundX, FoundY, 637, 487, 1000, 641, *12 DragonRuins.png
Can you explain what adding the variation does?

Tried it out and now it seems to find it perfectly.
neomulemi6
Posts: 216
Joined: 30 Jun 2016, 06:01

Re: need help using imagesearch

17 Jul 2017, 23:03

From the documentation:
*n (variation): Specify for n a number between 0 and 255 (inclusive) to indicate the allowed number of shades of variation in either direction for the intensity of the red, green, and blue components of each pixel's color. For example, *2 would allow two shades of variation. This parameter is helpful if the coloring of the image varies slightly or if ImageFile uses a format such as GIF or JPG that does not accurately represent an image on the screen. If you specify 255 shades of variation, all colors will match. The default is 0 shades.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: phalanxdarken and 116 guests