Issues with image search

Ask gaming related questions (AHK v1.1 and older)
Zukurah
Posts: 9
Joined: 22 Nov 2015, 15:24

Issues with image search

30 Nov 2015, 07:38

having trouble with image search

ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, *directory*
If Errorlevel = 0
loop, {
Sleep, %clicksleep%
RandClick2Area(37, 153, 485, 503)
ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, *Directory*
If errorlevel = 1
break
}
If errorlevel = 1

and it continues to image search using the same format above
I had this script working yesterday however at this point
its going into the loop after the first image detection, and its not scanning for the second imagine inside of the loop
that sends the break command
Zukurah
Posts: 9
Joined: 22 Nov 2015, 15:24

Re: Issues with image search

30 Nov 2015, 07:44

so i tried

ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, *directory*
If Errorlevel = 0
loop, {
Sleep, %clicksleep%
RandClick2Area(37, 153, 485, 503)

msgbox b4 imgsrch
ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, *Directory*
msgbox after imgsrch

If errorlevel = 1
break
}
If errorlevel = 1


it is indeed running the second image search but for some reason when the image is gone, it continues to think the image is still there
im not sure how to refresh that
grant
Posts: 323
Joined: 14 Oct 2015, 17:27

Re: Issues with image search

30 Nov 2015, 08:22

This is what makes image search so difficult, we can no *see* what you see.
I tested this on a static image and made some modifications so I can more easily see where we are getting what results and manually change the screen at some time.

Code: Select all

f4::


ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, c:\scripting\image\rune1.png

If Errorlevel = 0
loop, 
	{
	Sleep, 1000
	msgbox, RandClick2Area(37`, 153`, 485`, 503)
msgbox, image changes here searching in loop
msgbox, before search
	ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, c:\scripting\image\rune1.png
msgbox, after search
	If errorlevel = 1
		{
		msgbox, loop search error
		break
		}
	}
If errorlevel = 1
msgbox, main error
return
		
So you look for the image and find it (errorlevel = 0) and enter the loop.
Then you click and wait
you check for that image again inside the loop
when found (errorlevel = 0) the loop restarts and clicks again checking inside the loop again
The only way to exit is if the image changes resulting in (errorlevel = 1)
and we break the loop

That is how it works for me anyway.

And at this point I thought I fixed something accidentally and could not find it so I did it all again with less neatening the code. sigh....

Code: Select all

f6::


ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, c:\scripting\diablo2\rune1.png
If Errorlevel = 0
loop, {
msgbox, Sleep`, %clicksleep%
msgbox, RandClick2Area(37`, 153`, 485`, 503)

msgbox b4 imgsrch
ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, c:\scripting\diablo2\rune1.png
msgbox after imgsrch

If errorlevel = 1
break
}
If errorlevel = 1
return
And got the exact same result.

Might I suggest you include the mouse x and y locations in your code. No reason to use them later but they are generated anyway and it does help if you need to find unexpected results.
Zukurah
Posts: 9
Joined: 22 Nov 2015, 15:24

Re: Issues with image search

02 Dec 2015, 14:40

ok so i think there is an easier way for me to get what im trying to do, is it possible to do something along the lines of

If Imagesearch1
errorlevel=1
and imagesearch2
errorlevel=1
and imagesearch3
errorlevel=1
etc etc
then

to give u an idea of what im trying to do
there are a couple images i do not have(maybe, i have directory files for the pictures however with color calibrations and changes in resolution i wouldn't hjave the slightest idea how to match it to an exact pixel to pixel replica of whats displayed on the screen)
so what i've done is i've recorded all the OTHER images
and im trying to find a way to basically say, if none of these images appear - click, x,y


so strangely enough (i ahve no idea why)

ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, C:\Users\Zukura\Desktop\Misc\pokemon Shots\Autohunt\Hoothoot.bmp
If Errorlevel = 0
loop, {
Sleep, %clicksleep%
RandClick2Area(189, 249, 535, 570)
ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, C:\Users\Zukura\Desktop\Misc\pokemon Shots\Battleflag.bmp
If errorlevel = 1
break
}
If errorlevel = 1

"battleflag.bmp" i removed from the folder (it no longer exists in that directory) the script runs perfectly ( i have no idea why)

i use that block of code inside of a loop over and over again changing the BMP file to search for different images
currently this script works but i would like to expand its capabilities
to make responses when none of my images are found
grant
Posts: 323
Joined: 14 Oct 2015, 17:27

Re: Issues with image search

02 Dec 2015, 16:37

Glad tomsee you are making progress, and yes, you can do that but it gets ugly to look at and follow. Indent your searches to help read the code. Try to use the color variance option for image search. I think it is something li,e this, sorry on mobile device and not able to look at manual.
ImageSearch,,,0,0,A_ScreenWidth,A_ScreenHeight, *50 C:\Users\Zukura\Desktop\Misc\pokemon Shots\Autohunt\Hoothoot.bmp
That shoul give a variance in the colors of the image, play with it a bit.

I would be worried about why the size of the images change. The only way that happens is if the zoom changes ingame, you might want to check if this is the case or if it is some other unexpected error, see my next comment.....

Include errorlevel2 messages in your code. Yes, you might never get there, but do not be, lazey, it will pay off one day when you accidently rename the folder and everything breaks. Give a detailed message box in the program so you know exactly what to fix if it ever happens. Make it 5 lines long if you have to.

Return to “Gaming Help (v1)”

Who is online

Users browsing this forum: No registered users and 75 guests