Drew Posted June 4, 2007 Posted June 4, 2007 (edited) I don't understand how to make the cursor search for a certain given color and click it. **Also , once I do figure that first part out, what if there are 2 of the exact same color , how will it know which to pick? EDIT and while im at it on asking stupid questions , (i already tried looking in the help dept. so please don't shoo me off there.) How would i make a message window that I created , stay on top... and whats the func. to start with a hotkey... Edited June 4, 2007 by Drew
thetwistedpanda Posted June 4, 2007 Posted June 4, 2007 (edited) Opt("PixelCoordMode", 2) #include <GUIConstants.au3> GUICreate("Pixel Search", 200, 200, Default, Default) GUICtrlCreateIcon(@ProgramFilesDir & "\AutoIt3\Icons\au3.ico", -1, 76, 64, 48, 48) GUISetState() $Pixel = PixelSearch(25, 25, 150, 150, "0x6097D1", 5, 1) If Not @Error Then MsgBox(4096, "Pixel Results", "X: " & $Pixel[0] & ", Y: " & $Pixel[1]) EndIf While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Exit I'll give this one a shot. The help file basically states that in order for PixelSearch to work, you need a rectangle (i.e, 4 separate points). A left point, a high point, a right point, and a low point, making a rectangle if there were lines drawn. I don't know if the above example will work, but it should. PixelSearch is going to search inside of the rectangle I provided for a certain color, say "0x6097D1". There's a 'shade variation' of 5, which means it's not going to be exact, but it's going to be very close. From the help file: "The search is performed left-to-right, top-to-bottom and the first match is returned." - this should answer the question concerning multiple colors. Once it finds the appropriate color (or shade variant), it returns a two-element array of the pixel's coordinates (In this case, $Pixel[0] and $Pixel[1]). Now that the coordinates are found, making it click is relatively easy: MouseClick("left", $Pixel[0], $Pixel[1], 1, 10) for example. It would be wise to include this line of code inside of the If Not @Error Then statement, as if the color is not found, this will produce a lovely error. *Edit* - I seem to have skipped a question haha. If you mean message window as in MsgBox(), I have no idea, but for a gui, you could try $WS_EX_TOPMOST in the Gui's extended style section thing *End Edit* And to answer your final question, I believe you're looking for HotKeySet ( "key" [, "function"] ) Hope this helps - If not, I'm sure more experienced members will be along within the next four to eight hours to help ya out. Edited June 4, 2007 by thetwistedpanda
Drew Posted June 4, 2007 Author Posted June 4, 2007 No , your doing just fine. lol , im somewhat understanding this ( but im new so yeah ). Couple questions, Whered did you come up with "certain color, say "0x6097D1"". Or how did you come up with that color i mean. I think I understand on pixel coordinates for a particular rect. for it to search it. That sounds simple. I just don't know how to get the ###'s for a color.
Drew Posted June 4, 2007 Author Posted June 4, 2007 WOW ... I think i answered my own question this time. AutoIt Window Info works WONDERS lol. I love autoit
thetwistedpanda Posted June 4, 2007 Posted June 4, 2007 WOW ... I think i answered my own question this time. AutoIt Window Info works WONDERS lol. I love autoit Haha Yep, that's what I used.
Drew Posted June 4, 2007 Author Posted June 4, 2007 (edited) alright that didn't take long.. back for help. In your example it has these for the 4 rect. points ( 25, 25, 150, 150 ) I thought a mouse point had two coordinates ( x, y ) so that would take 2 numbers eg: 5,731 I don't understand how one number represents a position on the screen >< I have to be missing something unless you only need one coordinate ( x or y ) for one corner. I'm in a state of confusion atm , please help >< EDIT whats STEP , on the last part of all that [, step]] ) Edited June 4, 2007 by Drew
Drew Posted June 4, 2007 Author Posted June 4, 2007 Heres the code I have so far. CODEOpt("MouseClickDragDelay", 5000) Opt("PixelCoordMode", 2) #include <GUIConstants.au3> GUICreate("Pixel Search", 200, 200, Default, Default) GUICtrlCreateIcon(@ProgramFilesDir & "\AutoIt3\Icons\au3.ico", -1, 76, 64, 48, 48) GUISetState() PixelSearch ( 5, 138, 796, 615, 0x745028 [, 5] [, 1]] ) If Not @Error Then MsgBox(4096, "Pixel Results", "X: " & $Pixel[0] & ", Y: " & $Pixel[1]) EndIf While 1 $msg = GUIGetMsg() Switch $msg Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete() Exit I copied and pasted and filled in what I thought I needed to. Here are the coordinates of the window I want it to search in: Top Left: 5,138 Top Right: 796, 141 Bottom left: 19, 615 Bottom Right: 793, 628 So I don't know If I used the right coordinates in my codeing , I guessed on whether to use X , or Y at each left, right, top, bottom point. This is the Error I recieved: PixelSearch ( 5, 138, 796, 615, 0x745028 [, 5] [, 1]] ) PixelSearch ( 5, 138, 796, 615, 0x745028^ERROR or something like that. I'm confused once again . I don't understand where I went wrong.
Developers Jos Posted June 4, 2007 Developers Posted June 4, 2007 @Drew, You would help yourself tremendiously when you first try to learn to walk before starting to run ..... Learn about proper AutoIt3 syntax first .. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Drew Posted June 4, 2007 Author Posted June 4, 2007 Well i just typed Autoit3 Syntax into the help search and it didn't give me anything about it. Can ya just try and explain what i need to know lol. I learn by practice.
Developers Jos Posted June 4, 2007 Developers Posted June 4, 2007 Well i just typed Autoit3 Syntax into the help search and it didn't give me anything about it.Can ya just try and explain what i need to know lol. I learn by practice.start here SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
Drew Posted June 4, 2007 Author Posted June 4, 2007 NOOOOOOOOOOOOOOOO i tried that already. couldn't even get past the basic exam.
Drew Posted June 4, 2007 Author Posted June 4, 2007 okay i tried that again... the voice is shit and i can't understand any of it... therefor useless to me. I still need help
Developers Jos Posted June 4, 2007 Developers Posted June 4, 2007 NOOOOOOOOOOOOOOOO i tried that already. couldn't even get past the basic exam.Now what did that tell you ? okay i tried that again... the voice is shit and i can't understand any of it... therefor useless to me.I still need help Goto Start: SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past.
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