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?
ImageSearch Large Image fail
-
- Posts: 39
- Joined: 15 Oct 2017, 10:15
Re: ImageSearch Large Image fail
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
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
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
-
- Posts: 39
- Joined: 15 Oct 2017, 10:15
Re: ImageSearch Large Image fail
I am sorry i forgot to post my code
this code also tests for all variations
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
Re: ImageSearch Large Image fail
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.
Some of my AHK programs: 3D Voxel Game - Platformer Game
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
GitHub projects : Image/Pixel scanning class - Direct2D overlay class
Re: ImageSearch Large Image fail
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.
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.
-
- Posts: 39
- Joined: 15 Oct 2017, 10:15
Re: ImageSearch Large Image fail
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
Re: ImageSearch Large Image fail
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?
Also, can you post your full code including where you assign the values of all the variables?
-
- Posts: 39
- Joined: 15 Oct 2017, 10:15
Re: ImageSearch Large Image fail
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.
-
- Posts: 39
- Joined: 15 Oct 2017, 10:15
Re: ImageSearch Large Image fail
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 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
Re: ImageSearch Large Image fail
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?
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?
-
- Posts: 39
- Joined: 15 Oct 2017, 10:15
Re: ImageSearch Large Image fail
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
Re: ImageSearch Large Image fail
Remove the quotation marks around the filename in your ImageSearch command.