AutoHotkey Community

It is currently May 27th, 2012, 1:37 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: ImageSearch not working
PostPosted: November 22nd, 2009, 2:25 am 
I cannot get the imagesearch to work, even though I know the picture is on the screen. Am I doing anything wrong?


Code:
F2::


ImageSearch, , , 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\Chris\Desktop\istest\l158palace.bmp

if ErrorLevel = 2
    MsgBox Could not conduct the search.
else if ErrorLevel = 1
    MsgBox Icon could not be found on the screen.
else
    MsgBox The icon was found.

return
[/code]


Report this post
Top
  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 4:12 am 
Offline

Joined: December 21st, 2008, 7:29 pm
Posts: 181
Try adding CoordMode, Pixel so it looks at the whole screen rather than the coords of the active window. Also make sure the image you are searching with is cropped to the necessary area only, and make sure you read the Remarks section on ImageSearch

Code:
F2::
CoordMode, Pixel
ImageSearch,,, 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\Chris\Desktop\istest\l158palace.bmp

if ErrorLevel = 2
    MsgBox Could not conduct the search.
else if ErrorLevel = 1
    MsgBox Icon could not be found on the screen.
else
    MsgBox The icon was found.

return


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 22nd, 2009, 4:16 am 
Offline

Joined: July 18th, 2006, 12:18 pm
Posts: 403
Paul67 wrote:
I cannot get the imagesearch to work, even though I know the picture is on the screen. Am I doing anything wrong?


Code:
F2::


ImageSearch, , , 0, 0, A_ScreenWidth, A_ScreenHeight, C:\Users\Chris\Desktop\istest\l158palace.bmp

if ErrorLevel = 2
    MsgBox Could not conduct the search.
else if ErrorLevel = 1
    MsgBox Icon could not be found on the screen.
else
    MsgBox The icon was found.

return
[/code]


1: Dont use BMP's with ImageSearch unless you have read the manual very closely.
2: Put the image in the script directory and try that, Operating system/firewall maybe blocking these from being accessed by other programs.

I recommend using PNG for the imagesearch.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 22nd, 2009, 5:57 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6071
Location: San Diego, California
Quote:
I know the picture is on the screen.

Your coding looks good, except "CoordMode, Pixel " as entropic suggested.
Here are some other areas I have found, some repetition wih previous poster.
1. BMPs must be at least 16 bit (per manual) I usually use 24 bit
2. Is the image you are searching for fully visible ?
3. Is the image area part of your program or another ?
4. is the image im a game or in some other program ? games are sometimes hard/impossible to do imagesearch and pixelseaches on.
5. Try adding a fake image of your own and verify that the search can find it.
Here's example code, place it before your ImageSearch:

Code:
%image%=C:\Users\Chris\Desktop\istest\l158palace.bmp  ; <--- this is your image

Gui, -Caption  gui, margin, 0, 0
gui, add, picture, section vmybutton , %image%
gui, show,xcenter ycenter


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

All times are UTC [ DST ]


Who is online

Users browsing this forum: Apollo, bobbysoon, iDrug, Tipsy3000 and 15 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