AutoHotkey Community

It is currently May 26th, 2012, 8:10 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 12 posts ] 
Author Message
 Post subject: ImageSearch
PostPosted: June 19th, 2008, 8:45 pm 
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?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2008, 8:52 pm 
Try adding a / before the image file.


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2008, 8:55 pm 
Nice guess! But no... didn't work.. Any more suggestions?


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2008, 9:01 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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)


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2008, 9:04 pm 
Online
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3329
Location: Simi Valley, CA
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!


Report this post
Top
 Profile  
Reply with quote  
 Post subject: Re: ImageSearch
PostPosted: June 19th, 2008, 9:11 pm 
Offline

Joined: April 18th, 2008, 7:57 am
Posts: 1390
Location: The Interwebs
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] :P 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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 19th, 2008, 9:37 pm 
Online
User avatar

Joined: October 7th, 2006, 8:45 am
Posts: 3329
Location: Simi Valley, CA
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 :P

_________________
Ternary (a ? b : c) guide     TSV Table Manipulation Library
Post code inside [code][/code] tags!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2009, 5:49 pm 
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 :).

I've used image search a lot with relative addressing without any problems.


Report this post
Top
  
Reply with quote  
 Post subject: Another question
PostPosted: July 14th, 2009, 7:57 pm 
Offline

Joined: June 18th, 2009, 11:13 pm
Posts: 73
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


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: July 14th, 2009, 8:53 pm 
Offline

Joined: January 23rd, 2008, 6:38 pm
Posts: 162
I believe you would need 599,599,701,701 but i haven't verified it. Though it should be pretty easy to check.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 27th, 2011, 12:59 pm 
Offline

Joined: June 23rd, 2011, 8:26 am
Posts: 15
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.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: June 28th, 2011, 2:30 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6065
Location: San Diego, California
Hi Zeleene, welcome to the forum.

Thanks for trying to help others. :)

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


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ] 

All times are UTC [ DST ]


Who is online

Users browsing this forum: [VxE], Bing [Bot], BrandonHotkey, Google Feedfetcher, over21, SifJar, StepO and 69 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group