ImageSearch Large Image fail

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
clow_yakayi
Posts: 39
Joined: 15 Oct 2017, 10:15

ImageSearch Large Image fail

15 Oct 2017, 19:02

I am trying to find a larger image then usual, 71x71 pixels
it fails even when comparing just a screenshot
i don't understand the deal?
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: ImageSearch Large Image fail

15 Oct 2017, 19:39

First off, it's impossible for us to know what's going wrong when you don't provide any code =P

Secondly, make sure to read up on the ImageSearch docs, specifically about variation, sometimes pixels can be a few shades different, adding some variation to imagesearch will help.

ImageSearch, FoundX, FoundY, 5,5, 100, 100, *15 image.png ;15 shades of variation
clow_yakayi
Posts: 39
Joined: 15 Oct 2017, 10:15

Re: ImageSearch Large Image fail

15 Oct 2017, 19:45

I am sorry i forgot to post my code

Code: Select all

Loop
{
	ImageSearch, ImgX, ImgY, 0, 0, %VirtualWidth%, %VirtualHeight%, *%n% cook-taitinn-carp.png
	if ErrorLevel = 0
		MsgBox Found %n%
	else
		n++
	if(n == 255)
		MsgBox no variations
}

this code also tests for all variations
User avatar
Spawnova
Posts: 554
Joined: 08 Jul 2015, 00:12
Contact:

Re: ImageSearch Large Image fail

15 Oct 2017, 19:57

A variation of 255 would match anything so seems like something else is incorrect, check the errorlevel after the search, if it's 2 there was a problem, make sure your variables contain the expected values and the image since it has no path is assumed to be in your script directory.
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: ImageSearch Large Image fail

15 Oct 2017, 20:17

Note that the search is done relative to whatever window is active when the code runs unless you change the CoordMode.

As Spawnova mentioned, make sure the values for VirtualWidth, VirtualHeight, and n (n has no value the first time through the loop, anyway) are defined somewhere. As I mentioned in your other thread, you don't need % around VirtualWidth and VirtualHeight.

It's best to show all of what would make it a working piece of code, not for us to assume everything else it right since something is obviously not right.
clow_yakayi
Posts: 39
Joined: 15 Oct 2017, 10:15

Re: ImageSearch Large Image fail

16 Oct 2017, 09:21

My Coordmode is Screen, and now i just realized that even if the image exist it gives me 2 error codes one for not being found and one for not being existent 1,2
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: ImageSearch Large Image fail

16 Oct 2017, 09:49

It gives one or the other. Is it giving an ErrorLevel of 2?

Also, can you post your full code including where you assign the values of all the variables?
clow_yakayi
Posts: 39
Joined: 15 Oct 2017, 10:15

Re: ImageSearch Large Image fail

16 Oct 2017, 14:21

I have decided to move on to use a plugin ahk script, FindCLick. Much more easier once i figured out the options, and finds much better.
clow_yakayi
Posts: 39
Joined: 15 Oct 2017, 10:15

Re: ImageSearch Large Image fail

17 Oct 2017, 13:01

OK I am back, and i ran into this with both image search and find click, image search says no image found. I have the image in the appropriate place so confused about error level 2
code is here

Code: Select all

SetWorkingDir "the folder the image is in"
x:=0
y:=0
ImageSearch, x, y, 0, 0, VirtualWidth, VirtualHeight, *20 *Transblack "Lemon.png"
if ErrorLevel = 0
	MsgBox %x% %y%
if ErrorLevel = 1
	MsgBox not found
if ErrorLevel = 2
	MsgBox no image
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: ImageSearch Large Image fail

17 Oct 2017, 13:37

One problem is your script still does not assign values to VirtualWidth and VirtualHeight. You assigned values to x and y, which is not necessary, but it is necessary to have values for VirtualWidth and VirtualHeight (or just use numbers instead of variables).

If you're getting ErrorLevel of 2, then your path is probably not correct. Can you show the actual full line from your script for SetWorkingDir so we can see if you have a problem with how you identified the path?
clow_yakayi
Posts: 39
Joined: 15 Oct 2017, 10:15

Re: ImageSearch Large Image fail

17 Oct 2017, 13:50

Code: Select all

CoordMode, Pixel, Screen
CoordMode, Mouse, Screen
SysGet, VirtualWidth, 78
SysGet, VirtualHeight, 79
SetWorkingDir C:\Users\Andre\OneDrive\Documents\AHK\mabinogi\Inv
x:=0
y:=0
ImageSearch, x, y, 0, 0, VirtualWidth, VirtualHeight, *20 *Transblack "Lemon.png"
if ErrorLevel = 0
	MsgBox %x% %y%
if ErrorLevel = 1
	MsgBox not found
if ErrorLevel = 2
	MsgBox no image
my full code
User avatar
boiler
Posts: 16900
Joined: 21 Dec 2014, 02:44

Re: ImageSearch Large Image fail

17 Oct 2017, 16:23

Remove the quotation marks around the filename in your ImageSearch command.

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], mcd, ReyAHK and 247 guests