 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Paul67 Guest
|
Posted: Sun Nov 22, 2009 1:25 am Post subject: ImageSearch not working |
|
|
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] |
|
| Back to top |
|
 |
entropic
Joined: 21 Dec 2008 Posts: 181
|
Posted: Sun Nov 22, 2009 3:12 am Post subject: |
|
|
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
|
|
|
| Back to top |
|
 |
i3egohan
Joined: 18 Jul 2006 Posts: 403
|
Posted: Sun Nov 22, 2009 3:16 am Post subject: Re: ImageSearch not working |
|
|
| 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. |
|
| Back to top |
|
 |
Leef_me
Joined: 08 Apr 2009 Posts: 5333 Location: San Diego, California
|
Posted: Sun Nov 22, 2009 4:57 am Post subject: |
|
|
| 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 |
|
|
| Back to top |
|
 |
|
|
You can post new topics in this forum You can reply to topics in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|