AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

ImageSearch

 
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Jessie
Guest





PostPosted: Thu Jun 19, 2008 7:45 pm    Post subject: ImageSearch Reply with quote

Erm, my question is how do you image search for a image in your folder?


I mean like:

ImageSearch.ahk (is in folder A)
image.bmp (is in folder A)

when I do:
ImageSearch, FoundX, FoundY, 0,0, 2000, 2000, inventory.bmp

it gives me ErrorLevel2 which means it can't find the image location...

any help?
Back to top
Josh
Guest





PostPosted: Thu Jun 19, 2008 7:52 pm    Post subject: Reply with quote

Try adding a / before the image file.
Back to top
Jessie
Guest





PostPosted: Thu Jun 19, 2008 7:55 pm    Post subject: Reply with quote

Nice guess! But no... didn't work.. Any more suggestions?
Back to top
Krogdor



Joined: 18 Apr 2008
Posts: 1390
Location: The Interwebs

PostPosted: Thu Jun 19, 2008 8:01 pm    Post subject: Reply with quote

If the script and the image are both in the same directory, what you have posted should work... But, try providing an absolute path for the image file (e.g. C:\Documents\Whatever\inventory.bmp)
Back to top
View user's profile Send private message AIM Address
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Thu Jun 19, 2008 8:04 pm    Post subject: Reply with quote

I'm guessing that theproblem is in the region specified for the image search. You should try
Code:
Coordmode, pixel, screen
ImageSearch, FoundX, FoundY, 0,0, %A_ScreenWidth%, %A_ScreenHeight%, image.bmp


To answer your other question:
You can either specify an absolute path to the image.
Code:
ipath = %A_MyDocuments%\Ahk Macros\image.bmp
;...
ImageSearch, FoundX, FoundY, 0,0, %A_ScreenWidth%, %A_ScreenHeight%, %ipath%


or you can set the working directory to the folder that has the image
Code:
SetWorkingDir, %A_MyDocuments%\Ahk Macros\
;...
ImageSearch, FoundX, FoundY, 0,0, %A_ScreenWidth%, %A_ScreenHeight%, image.bmp


or you can search a folder and subfolders for an image with a matching name
Code:
Loop, %A_MyDocuments%\image.bmp, 0, 1
   ipath = %A_LoopFileLongPath%
;...
ImageSearch, FoundX, FoundY, 0,0, %A_ScreenWidth%, %A_ScreenHeight%, %ipath%


And, no matter which way you choose, using
Code:
IfNotExist %YourImageFilePathAndName%
   MsgBox Dur! script es muy stupido`nFile not found.
should at least tell you if the script can find the file.
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
Krogdor



Joined: 18 Apr 2008
Posts: 1390
Location: The Interwebs

PostPosted: Thu Jun 19, 2008 8:11 pm    Post subject: Re: ImageSearch Reply with quote

Jessie wrote:

it gives me ErrorLevel2 which means it can't find the image location...

[VxE] wrote:
I'm guessing that theproblem is in the region specified for the image search.


Read the poster a little more carefully, [VxE] Razz Even if you didn't know the ErrorLevel 2 means the script can't open the image file, he says it right there. Silly boy.
Back to top
View user's profile Send private message AIM Address
[VxE]



Joined: 07 Oct 2006
Posts: 3254
Location: Simi Valley, CA

PostPosted: Thu Jun 19, 2008 8:37 pm    Post subject: Reply with quote

The Manual wrote:
ErrorLevel is set to 0 if the image was found in the specified region, 1 if it was not found, or 2 if there was a problem that prevented the command from conducting the search (such as failure to open the image file or a badly formatted option).

Errorlevel 2 could mean several things. But it's true that I don't have much experience with imagesearch Razz
_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!
Back to top
View user's profile Send private message
silkcom-offline
Guest





PostPosted: Tue Jul 14, 2009 4:49 pm    Post subject: Reply with quote

Is it just me or is image.bmp not equal to inventory.bmp. I assume that this isn't the mistake, but it's obvious which usually is right Smile.

I've used image search a lot with relative addressing without any problems.
Back to top
skyd1v3r



Joined: 18 Jun 2009
Posts: 73

PostPosted: Tue Jul 14, 2009 6:57 pm    Post subject: Another question Reply with quote

Another question on imagesearch:

Letīs say I want to search an image of 100*100.
I have found that the upper left corner is at 600/600.

Can I specify the coordinates to search with 599,599,601,601?
Or do I need to use 599,599,701,701?

With other words, does the complete image need to be withhon the parameters, or only the upper left corner?

Choosing tight coorinates is a matter of performance withhin loops...

Thanks
Back to top
View user's profile Send private message
silkcom



Joined: 23 Jan 2008
Posts: 162

PostPosted: Tue Jul 14, 2009 7:53 pm    Post subject: Reply with quote

I believe you would need 599,599,701,701 but i haven't verified it. Though it should be pretty easy to check.
Back to top
View user's profile Send private message
Zeleene



Joined: 23 Jun 2011
Posts: 15

PostPosted: Mon Jun 27, 2011 11:59 am    Post subject: Reply with quote

skyd1v3r:

This shouldnt matter. If you put 600,600,10000000,10000000
the 2nd number shouldnt matter since the first thing the ImageSearch does is find the picture @ 600,600

So even if you want to do it 599,599,601,601 (if this doesnt work) you could just aswell do 600,600,A_ScreenWidth,A_ScreenHight

I have not verified this but its the most logical result.
Back to top
View user's profile Send private message
Leef_me



Joined: 08 Apr 2009
Posts: 5333
Location: San Diego, California

PostPosted: Tue Jun 28, 2011 1:30 am    Post subject: Reply with quote

Hi Zeleene, welcome to the forum.

Thanks for trying to help others. Smile

But I'll point out the following things:

1. The thread is almost 24 months old
2. the user you responded to has not posted in over 20 months.
3. you gave an answer that you didn't test
4. you gave an answer that doesn't address the question
5. you gave an "the 2nd number shouldnt matter" which is wrong
(you probably meant "the 2nd corner", and you are still wrong)

skyd1v3r wrote:

With other words, does the complete image need to be withhon the parameters, or only the upper left corner?

6. The proper answer is Yes, the complete image must be within the search area

skyd1v3r wrote:

Choosing tight coorinates is a matter of performance withhin loops...

7. Finding an image using coordinates of 600,600,10000000,701 will take longer to search than 600,600,701,701
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group