AutoHotkey Community

It is currently May 26th, 2012, 11:42 pm

All times are UTC [ DST ]




Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next
Author Message
PostPosted: November 8th, 2009, 4:45 am 
Offline

Joined: November 7th, 2009, 12:01 pm
Posts: 60
I've tried imagesearching for a small (about 20x20) box that has a mix of two colours. But while testing it out, I always get the answer yes in this script:

Code:
^H::
Imagesearch, X,Y, 1003,52,1061,111, C:\Users\My Documents\Pictures\test.png
if errorlevel,
   msgbox, no
else,
   msgbox, yes
return


I don't understand why. Even when I have a completely white background (which the image has shades of grey and black) it still sends me the answer yes...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 4:56 am 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
Your allowing for 111 offset. Change it to about 20.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:09 am 
Offline

Joined: November 7th, 2009, 12:01 pm
Posts: 60
Uhh sorry, could you please repeat that in layman terms?


Report this post
Top
 Profile  
Reply with quote  
PostPosted: November 8th, 2009, 5:13 am 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
Puttah wrote:
Code:
^H::
Imagesearch, X,Y, 1003,52,1061,111, C:\Users\MyDocuments\Pictures\test.png
if errorlevel,
   msgbox, no
else,
   msgbox, yes
return

Try changing the number 111 to a lower number.
The number tells the script how far off the picture can be, on the scale of 0 (perfect match) to 255 (everything matches).


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:14 am 
Offline

Joined: March 27th, 2009, 10:48 pm
Posts: 71
Code:
^H::
Imagesearch, X,Y, 1003,52,1061,111, C:\Users\My Documents\Pictures\test.png
if errorlevel,
   msgbox, no
else,
   msgbox, yes
return


It should be this:
Code:
^H::
Imagesearch, X,Y, 1003,52,1061,20, C:\Users\My Documents\Pictures\test.png
if errorlevel,
   msgbox, no
else,
   msgbox, yes
return


Either 20 or lower is good


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:14 am 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
Ninjad!! :twisted:


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:17 am 
Offline

Joined: November 7th, 2009, 12:01 pm
Posts: 60
Oh haha those are meant to be the coordinates, right?

I mean, the top left corner should be at 1003,52
and the bottom right corner should be at 1061,111

And yeah I would only put the offset to about 10 max. So how could I write this line in order to get 10 offset and still have my imagesearch box coordinates defined as so?


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:27 am 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
Omg....
Im a noob!!!!! :evil: :evil: :evil: :evil: :evil:
Sorry I barely glanced at the code.
Your right, those are just coordinates.
Anyways...
I don't normally use ErrorLevel for ImageSearch... I would do this...
Code:
^H::
X=
Y=
Imagesearch, X,Y, 1003,52,1061,111,15, C:\Users\My Documents\Pictures\test.png ;The 15 is the offset

If X= ;If X is empty after the search
{
   msgbox, no
}

If X<> ;If X isn't empty after the search
{
   msgbox, yes
}
return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:38 am 
Offline

Joined: November 7th, 2009, 12:01 pm
Posts: 60
Ahh it's ok :P

Well, I tested that one out and it sure has made a difference. Now I always get "no" as a result even when the picture is there. I even bumped up the offset to a massive 150, and still get the same result - so maybe the script has a typo or something in it? (is that what a bug in computer language means?)

And I would still prefer to use errorlevel, since I've got quite a few imagesearches in one script.

I used to write scripts, but after a year's break, everything just flies out the window and you're left with nothing but blurry and fuzzy memories.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:48 am 
Offline

Joined: October 15th, 2007, 3:10 pm
Posts: 790
Location: England
@Ace Coder & BF2: That's not how you put the variation in! :D

Try this:
Code:
^H::
X := ""
Y := ""
Imagesearch, X, Y, 1003, 52, 1061, 111, *15 C:\Users\My Documents\Pictures\test.png ;The 15 is the variation
If ( ErrorLevel = 0 )
  MsgBox, Found the Image!!
Else If ( ErrorLevel = 1 )
  MsgBox, Image not found
Else
  MsgBox, ErrorLevel: %ErrorLevel% (2 indicates a problem of some kind)


Last edited by OceanMachine on November 8th, 2009, 5:54 am, edited 4 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:49 am 
Online

Joined: April 8th, 2009, 7:49 pm
Posts: 6068
Location: San Diego, California
Silly noobies :wink: It's NOT is a problem with the ImageSearch command

Code:
errorlevel=0

if errorlevel, ; <-------- FAILS WHEN YOU USE THE COMMA!
   msgbox, no
else,
   msgbox, yes
;return


errorlevel=1

if errorlevel, ; <-------- FAILS WHEN YOU USE THE COMMA!
   msgbox, no
else,
   msgbox, yes
;return



errorlevel=0

if errorlevel ; <-------- WORKS WITHOUT THE COMMA!
   msgbox, no
else,
   msgbox, yes
;return


errorlevel=1

if errorlevel ; <-------- WORKS WITHOUT THE COMMA!
   msgbox, no
else,
   msgbox, yes
;return


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:53 am 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
:oops:
I hate my life...
Lol
A wise man once said...
Quote:
Ace Coder your a NOOB


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 5:54 am 
Offline

Joined: November 7th, 2009, 12:01 pm
Posts: 60
LOL Leef_me thanks for the help. OceanMachine you've answered my next question since I'm sure I would still be at a loss without that little asteriks :D

All these tiny bugs, making such a big difference in the output... how silly! :P

I'll see if this new found knowledge gets me somewhere. Be back in a sec!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 6:03 am 
Offline

Joined: November 7th, 2009, 12:01 pm
Posts: 60
Has "ace" lost all meaning now-a-days? haha jk, it's cool, looking on the bright side I'm even more noob :D

Ok this is the code I have now:

Code:
^H::
Imagesearch, X,Y, 1003,52,1061,111, *10, C:\Users\My Documents\Pictures\test.png

If errorlevel
   msgbox, no
else,
   msgbox, yes
return


Now it always says no. I even bumped up the offset to 255 to be sure, and yes, my suspicions were settled. Something is still wrong with the coding since I still get the msgbox no.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: November 8th, 2009, 6:12 am 
Offline

Joined: October 26th, 2009, 6:29 am
Posts: 362
Here I go again... :oops:
Code:
^H::
Imagesearch, X,Y, 1003,52,1061,111, *10, C:\Users\My Documents\Pictures\test.png

If ErrorLevel<>0
{
   MsgBox, No Ace Coder is still a noob!
}

If ErrorLevel=0
{
   MsgBox, YES!!! ACE DID SOMETHING RIGHT!!
}
Return


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 30 posts ]  Go to page 1, 2  Next

All times are UTC [ DST ]


Who is online

Users browsing this forum: Bing [Bot], Google [Bot], Google Feedfetcher, Leef_me, Pulover, rbrtryn, XstatyK, Yahoo [Bot] and 31 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