 |
AutoHotkey Community Let's help each other out
|
| View previous topic :: View next topic |
| Author |
Message |
Titan
Joined: 11 Aug 2004 Posts: 5009 Location: imaginationland
|
Posted: Wed Aug 11, 2004 1:52 am Post subject: Problem with PixelSearch... |
|
|
Hello, I have made a script and I am having a problem...
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 |
|
 |
BoBo Guest
|
Posted: Wed Aug 11, 2004 10:51 am Post subject: |
|
|
| 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  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Wed Aug 11, 2004 11:31 am Post subject: |
|
|
| 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 |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5009 Location: imaginationland
|
Posted: Fri Aug 13, 2004 4:57 pm Post subject: Still doesn't work... |
|
|
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.  |
|
| Back to top |
|
 |
Chris Site Admin
Joined: 02 Mar 2004 Posts: 10464
|
Posted: Fri Aug 13, 2004 5:40 pm Post subject: |
|
|
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 |
|
 |
Titan
Joined: 11 Aug 2004 Posts: 5009 Location: imaginationland
|
Posted: Sat Aug 14, 2004 10:14 pm Post subject: Working... |
|
|
Thanks, got it sussed now  |
|
| 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
|