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 

Problem with PixelSearch...

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
Titan



Joined: 11 Aug 2004
Posts: 5009
Location: imaginationland

PostPosted: Wed Aug 11, 2004 1:52 am    Post subject: Problem with PixelSearch... Reply with quote

Hello, I have made a script and I am having a problem... Question
Here is the code I took out from my script that I'm having problems with:

Code:
PixelSearch, Px, Py, 328, 247, 359, 274, 344170, 100
if ErrorLevel = 0
   MouseClick, left,  %Px%,  %Py%
else
   MsgBox, 21, Not Found, That color was not found in the specified region.,
IfMsgBox, Cancel
   ExitApp
Sleep, 10


The problem is with the first line, the bit where I'm supposed to put X1, Y1 (328, 247). Basically the script doesn't go look for the pixelcolour in the rectangle region but instead just hover's over the coordinate 328, 247 trying to find the colour on that point only. I have the latest version of AutoHotkey and have checked my script with the manual several times to make sure I'm not doing anything wrong, please assist me with the matter.
Back to top
View user's profile Send private message Visit poster's website
BoBo
Guest





PostPosted: Wed Aug 11, 2004 10:51 am    Post subject: Reply with quote

Quote:
of the first pixel that matches ColorID

Are you shure the pixel wasn't found at the position you've mentioned, so the search (scan) hasn't been stopped already Question
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Wed Aug 11, 2004 11:31 am    Post subject: Reply with quote

Quote:
PixelSearch, Px, Py, 328, 247, 359, 274, 344170, 100

Note that you are using a relatively large "shades of variation" (last parameter). This might result in the upper-left corner pixel in the region always (or almost always) being a match. This is because the upper left pixel is the first one to be searched. Consider reducing the value of shades-of-variation, perhaps to the default of zero.

I'm pretty sure PixelSearch works since many others have used it. I've used the command myself for fairly complex color searching and not had a problem with it.
Back to top
View user's profile Send private message Send e-mail
Titan



Joined: 11 Aug 2004
Posts: 5009
Location: imaginationland

PostPosted: Fri Aug 13, 2004 4:57 pm    Post subject: Still doesn't work... Reply with quote

I have changed it to 0 like you said but it still doesn't work. It goes to the first set of coordinates and searches for the pixels there and because it can't find it I always get the ErrorMessage. It should search for the colour in the rectangle region, please help. Crying or Very sad
Back to top
View user's profile Send private message Visit poster's website
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10464

PostPosted: Fri Aug 13, 2004 5:40 pm    Post subject: Reply with quote

It does search the region, but you have to be sure you have the right color. Sometimes the cursor might block the target color (such as in a game), in which case Window Spy would report the wrong color (i.e. the color of the cursor itself).

If you suspect that is the case, you could try a script like the below:

#z::
MouseGetPos, X, Y
; Move the cursor out of the way so that it doesn't block the pixel we want.
MouseMove, 10, 10, 5, R ; Move down and to the right a little.
Sleep, 50 ; Might need time to make it reliable.
PixelGetColor, color, %X%, %Y%
MouseMove, %X%, %Y%, 2
clipboard = X%X% Y%Y% Color = %color%
SplashTextOn, , , %clipboard%
return
Back to top
View user's profile Send private message Send e-mail
Titan



Joined: 11 Aug 2004
Posts: 5009
Location: imaginationland

PostPosted: Sat Aug 14, 2004 10:14 pm    Post subject: Working... Reply with quote

Thanks, got it sussed now Very Happy
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   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