lilandywandy Posted December 28, 2004 Share Posted December 28, 2004 i want to make a program that can "sense" things, this are some stuff i hope are possible it can do: 1.) lets use 100,100 as example co-ords. i want the program to "check" that spot for a color lets say 000000. and when its 000000 it does a set of commands, and if its another color, it does another set of commands, and it its another color it does nothing... this probably need those "ifs" commands im totally clueless.... ive only gone far enough to move mouse and make it click >< Link to comment Share on other sites More sharing options...
layer Posted December 28, 2004 Share Posted December 28, 2004 look in the helpfile for "PixelSearch"... that should get you going FootbaG Link to comment Share on other sites More sharing options...
ioliver Posted December 28, 2004 Share Posted December 28, 2004 Also, look in the help file for a While ... Wend Loop. Make sure you put a "Sleep" in the Loop, or it will eat up CPU Time. Hope that helps, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
lilandywandy Posted December 28, 2004 Author Share Posted December 28, 2004 no thats not what i mean well not atleast the main point.... i need help doing a functions that : check X,Y if x,y is "color", then do this, if not do nothing if x,y is "color2" then do this , if not do nothing if x.y is "color 3" then do this, if not do nothing repeat again and again Link to comment Share on other sites More sharing options...
SlimShady Posted December 28, 2004 Share Posted December 28, 2004 (edited) PixelGetColor.You specify the x and y coordinates and it returns the color. Edited December 28, 2004 by SlimShady Link to comment Share on other sites More sharing options...
ioliver Posted December 28, 2004 Share Posted December 28, 2004 (edited) Ok, then you'll also want to search the help file for an If ... Then Satement. But if you use all those things: While 1 $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want[ EndIf Wend Something like that should take care of you. Ian Edit: Formated the Code... Edited December 28, 2004 by ioliver "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
ezzetabi Posted December 28, 2004 Share Posted December 28, 2004 For using a more 'classic' emuneration of colors you can use $x = 10 $y = 10 $hHTMLCodeColor = 'FFFFFF'; FFFFFF is pure white... If PixelGetColor($x,$y) = Dec($hHTMLCodeColor) Then ;Ect... EndIf Link to comment Share on other sites More sharing options...
layer Posted December 28, 2004 Share Posted December 28, 2004 (edited) well, that's exactly waht PixelSearch does... heres an example: While 1 HotKeySet("^!p", "MyExit");PRESS CTRL+ALT+P TO EXIT! while 1;starts loop $coord = PixelSearch (x, x, y, y, 0xff0000, 0, 10);searches for pure red for every 10 pixels If Not @error Then;if the color is found MouseClick ("left", $coord[0], $coord[1], 1, 0);...if the color is found mouseclick where it was found EndIf;ends if statement wend;gose back to while 1 Func MyExit();exit func (user defined) Exit EndFunc EDIT: added Edited December 28, 2004 by layer FootbaG Link to comment Share on other sites More sharing options...
lilandywandy Posted December 29, 2004 Author Share Posted December 29, 2004 (edited) While 1 $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want[ EndIf Wend so...... if i want to do more then one While 1 $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want[ EndIf $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want[ EndIf $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want[ EndIf $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want[ EndIf $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want[ EndIf Wend is that correct? [Code to do what you want] how would that be on note pad? should i copy and paste or should there be no space and have ; before it Edited December 29, 2004 by lilandywandy Link to comment Share on other sites More sharing options...
ioliver Posted December 29, 2004 Share Posted December 29, 2004 (edited) If you a specific action to perform for more than one color, I would put the whole thing in a While ... Wend loop. And use Select ... Case to perform the actions.[Code to do what you want]how would that be on note pad? should i copy and paste or should there be no space and have ; before itThe [Code to do what you want] is just refering to the actions you want the Script to perform, if it finds the correct color. For example, if the script finds the right color you might want it to Run() a program or Send() some keystrokes.Check out the Bolded topics in the help file. It should give you a good place to start.IanEdit: Corrected Misspelling Edited December 29, 2004 by ioliver "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
lilandywandy Posted December 29, 2004 Author Share Posted December 29, 2004 While 1 $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For]Then [Code to do what you want] Else [Code to do something else, if you want[ EndIfWendlets say i want to do more then one of those, where owuld the endif and wend be? like this?While 1 $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For]Then [Code to do what you want] Else [Code to do something else, if you want] $color = PixelGetColor(x, y) If $color = [The Color You Are Looking For] Then [Code to do what you want] Else [Code to do something else, if you want] EndIfWend Link to comment Share on other sites More sharing options...
ioliver Posted December 29, 2004 Share Posted December 29, 2004 Lilandywandy, That's good, but you can't start a second If statement without closing the first If statement with and EndIf. (Well, you can, but that would be a nested loop, and that's not what you were trying to do here.)You code is:While 1$color = PixelGetColor(x, y)If $color = [The Color You Are Looking For] Then [Code to do what you want]Else [Code to do something else, if you want]$color = PixelGetColor(x, y)If $color = [The Color You Are Looking For] Then [Code to do what you want]Else [Code to do something else, if you want]EndIfWendYou have two If statements, and only one EndIf, so the Script will break. Try this instead:While 1$color = PixelGetColor(x, y)If $color = [The Color You Are Looking For] Then [Code to do what you want]Else [Code to do something else, if you want]$color = PixelGetColor(x, y)EndIfIf $color = [The Color You Are Looking For] Then [Code to do what you want]Else [Code to do something else, if you want]EndIfWendNotice that each If statement is closed with and EndIf.Hope that helps,IanIf you can describle some more about what you want to do, I may be able to come up with some better sample code. "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
ioliver Posted December 29, 2004 Share Posted December 29, 2004 Here's some sample code I put together that should work, and should help to get you started... ; Your resolution should be set to 1024 x 768 for this to work ; I haven't checked it whith other resolutions. ; To use this try painting the Box either White or Black... Run("c:\windows\system32\mspaint.exe", "", @SW_MAXIMIZE) While 1 $color = PixelGetColor(600, 225) If $color = "16777215" Then; 16777215 = White MsgBox(1, "Color", "White", 3) EndIf If $color = "0" Then; 0 = Black MsgBox(1, "Color", "Black", 3) EndIf Sleep(1000) WEnd Hope that helps, Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
Insolence Posted December 29, 2004 Share Posted December 29, 2004 Also make sure you have a sleep delay inside the loop, so it doesn't lag the computer too much. Try using a select/case setup: Select Case $color = xxxxx ;do stuff here Case $color = xxxxx ;do stuff here Case $color = xxxxx ;do stuff here EndSelect I think that's a lot cleaner then a bunch of If's "I thoroughly disapprove of duels. If a man should challenge me, I would take him kindly and forgivingly by the hand and lead him to a quiet place and kill him." - Mark TwainPatient: "It hurts when I do $var_"Doctor: "Don't do $var_" - Lar. Link to comment Share on other sites More sharing options...
lilandywandy Posted December 31, 2004 Author Share Posted December 31, 2004 lets say i want to do more then one of those, where owuld the endif and wend be? like this?<{POST_SNAPBACK}>i think this is what im trying to do but i dont dig you, : =(let me see if i can be lil more detailedi have 2 specific points on my desktop,i want the computer to check its colors every 5 secs[first coord]if the color is grey then it does "blah" if the color is white then it does "blah" it the color is blue then it does "blah" [end of first coord][2nd coord]if the color is brown then it does "blah" if not brown do nothing Link to comment Share on other sites More sharing options...
ioliver Posted January 3, 2005 Share Posted January 3, 2005 [first coord]if the color is grey then it does "blah"[2nd coord]if the color is brown then it does "blah" if not brown do nothingBecause PixelGetColor(), returns the Dec. value of the color, you will need to know the Dec. value of 'Grey' and 'Brown'. To find the Dec. value of a color, download xDrop.Untested Code:While 1 $color1 = PixelGetColor(first-coord-x, first-coord-y) If $color1 = [Dec. Value for Grey] Then [Code to do what you want] EndIf $color2 = PixelGetColor(second-coord-x, second-coord-y) If $color2 = [Dec. Value for Brown] Then [Code Here] EndIf Sleep(50) WEndLike I said, untested, but's that the general idea.Hope that helps,Ian "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
t0ddie Posted January 3, 2005 Share Posted January 3, 2005 Because PixelGetColor(), returns the Dec. value of the color, you will need to know the Dec. value of 'Grey' and 'Brown'. To find the Dec. value of a color, download xDrop.to find out the decimal value of the color, hold your mouse over it, and use the autoit window spy. Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you. Link to comment Share on other sites More sharing options...
ioliver Posted January 3, 2005 Share Posted January 3, 2005 (edited) to find out the decimal value of the color, hold your mouse over it, and use the autoit window spy.Thanks t0ddie, I haven't used AutoIt Spy much, I didn't realize it could do that. But, that would be a better way.Thanks again,IanEdit: Made some formatting changes. Edited January 3, 2005 by ioliver "Blessed be the name of the Lord" - Job 1:21Check out Search IMF Link to comment Share on other sites More sharing options...
Blue_Drache Posted January 3, 2005 Share Posted January 3, 2005 CODE Dim $blue = 255 ; pure blue #0000FF Dim $gray = 8421504 ; Middle gray #808080 Dim $black = 0 ; pure black #000000 Dim $brown = 8932100 ; My version of brown #884B04 Dim $sec = 1000 ; Shortuct for sleep timers. While 1 PixelGetColor($x, $y) Select Case $pixel = $blue ; do blah Case $pixel = $gray ; do blah-blah Case $pixel = $black ; do blibbity Case $pixel = $brown ; do bobbity EndSelect Sleep($sec * 5) WEnd Define $x and $y on your own. Lofting the cyberwinds on teknoleather wings, I am...The Blue Drache Link to comment Share on other sites More sharing options...
Administrators Jon Posted January 3, 2005 Administrators Share Posted January 3, 2005 (edited) Why not just drop the decimals and do:Dim $blue = 0x0000FF; pure blue #0000FFEdit: And if you are not already, check out the beta SPY at http://www.autoitscript.com/autoit3/files/...oit/AU3_Spy.exeIt has a maginfying glass and everything Edited January 3, 2005 by Jon Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now