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 

Color Help

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



Joined: 08 Mar 2005
Posts: 6

PostPosted: Tue Mar 08, 2005 1:20 am    Post subject: Color Help Reply with quote

Hi,
I am just looking for someone that would explain how "pixelsearch" and "pixelgetcolor" work.

I have read over the section in the guide on it, but, being 13, and fairly new at this isn't helping understand it.
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Tue Mar 08, 2005 2:24 am    Post subject: Reply with quote

PixelSearch
Searches an area of the screen for a colour you want.

PixelSearch, OutputVarX, OutputVarY, X1, Y1, X2, Y2, ColorID [, Variation, Fast|RGB]

OutputVarX/Y: The variable to store the x/y-coodinate of the point where the colour was found.
X1, Y1: The toper-leftmost point where the colour searching should start from.
X2, Y2: The bottom-right point where the colour searching should stop from.
ColorID: The colour code of the pixel you want to search for.
Variation: An 'allowance' for a different intensity of colour.
Fast|RGB: Making this 'Fast' means it will look for the colour faster, making it 'RGB' means it will use another method of searching.

Example:
You want to search for the colour Red on a section of the screen and move the mouse to it.
Code:
PixelSearch, X_Position, Y_Position, X1, Y1, X500, Y500, 0x0000FF, 10, Fast
If ErrorLevel = 0
MsgBox, The colour Red was found at x%X_Position% y%Y_Position%
MouseMove, %X_Position%, %Y_Position%


-------------------------------------------------------------------------------------

There's an explanation that I hope has made things a little clearer for you, if not I suggest you get an older person to help you to understand.
_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
jonny



Joined: 13 Nov 2004
Posts: 3004
Location: Minnesota

PostPosted: Tue Mar 08, 2005 2:38 am    Post subject: Reply with quote

Don't let age stop you. Very Happy I've got plenty of teenage friends who are very good at programming. It just takes some dedication and experience. As for those particular functions, I can't tell you much more that isn't in the docs, but I can try to explain it more simply.

PixelSearch: Finds the specified color in the specified area, and returns it's coordinate. The output is returned in the OutputVarX and OutputVarY parameters. X1 and Y1 are the coordinates for the upper left of the area to search in, and X2 and Y2 are the lower right coordinates. ColorID is the color to search for, in BGR (Blue-Green-Red) format. You usually don't have to worry about the last two parameters, Variation and Fast|RGB. If you have your screen set higher than 16-bit color, the Fast parameter is usually OK to set, and Variation helps with colors that may vary (Like, say, a winamp skin with a brightness setting, or a health meter in a game).

PixelGetColor: This is PixelSearch's counterpart; rather than finding the coordinate of a color, it finds the color of a coordinate. It's also simpler to use. The only OutputVar unsurprisingly returns the color of the pixel whose coordinate is specified in the X and Y parameters. The RGB parameter, if specified, returns the value in RGB rather than the default of BGR.

Edit: Titan beat me to it. Oh well, the more the merrier! Razz
Back to top
View user's profile Send private message
Hokum Dreamz



Joined: 08 Mar 2005
Posts: 6

PostPosted: Tue Mar 08, 2005 11:45 pm    Post subject: Reply with quote

Thank you, alot, helped out quite a bit.
If i wanted to find the color where ever my mouse cursor was, what would i use for the coords?
i have
Code:
f1::
pixelgetcolor,Color,,,RGB

and is there a way it would automatically show it in a highlitable input box or automatically put it on clipboard?
Back to top
View user's profile Send private message
Titan



Joined: 11 Aug 2004
Posts: 5068
Location: imaginationland

PostPosted: Wed Mar 09, 2005 12:07 am    Post subject: Reply with quote

Hokum Dreamz wrote:
If i wanted to find the color where ever my mouse cursor was
Code:
MouseGetPos, xmpos, ympos
PixelGetColor, Colour_UnderMouse, %xmpos%, %ympos%
Msgbox, the pixel colour under the mouse position is: %Colour_UnderMouse%

_________________

RegExReplace("irc.freenode.net/ahk", "^(?=(.(?=[\0-r\[]*((?<=\.).))))(?:[c-\x73]{2,8}(\S))+((2)|\b[^\2-]){2}\D++$", "$u3$1$3$4$2")
Back to top
View user's profile Send private message Visit poster's website
Hokum Dreamz



Joined: 08 Mar 2005
Posts: 6

PostPosted: Fri Mar 11, 2005 8:46 pm    Post subject: Reply with quote

Wewt <3 titan and jonny
tyvm =D
Back to top
View user's profile Send private message
guest
Guest





PostPosted: Fri Mar 11, 2005 8:55 pm    Post subject: Reply with quote

me 13 aswell - only just got autokey
i trying to do colours etc and its hard
my program so far (click a button over and over):

Code:
WinWaitActive, Dark Throne (beta) Recruitloop - Microsoft Internet Explorer
Sleep, 5000
MouseGetPos, Mouse 401, Mouse 464
PixelGetColor, color, %Mouse401%, %Mouse464%
If color is 144164
MouseClick, left, 401, 464
If color is not 144164
Return
Back to top
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Sat Mar 12, 2005 2:34 am    Post subject: Reply with quote

Don't use "is" and "is not" to compare a variable to a value. Instead, use = and <>:
Code:
If color = 144164
    MouseClick, left, 401, 464
else
    Return
Back to top
View user's profile Send private message Send e-mail
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