alex OF DEATH Posted January 25, 2007 Posted January 25, 2007 Here is my script: Func go() $clickpos = MouseGetPos() $color = pixelgetcolor ( $clickpos[0] , $clickpos[1] ) $Findnew = PixelSearch ( 519, 257, 1031, 593, $color ) if $findnew > 1 then mouseclick ( "left" , $Findnew[0] & $Findnew[1] ) endfunc Okay, so im trying to get a color of an object on the screen, then search an area for that color and click on it. Im a little bit confused on the pixel search parameters. It's really hard to explain what I think it means, but please just explain what it wants Also, it says that $findnew is a non array variable. Im pretty sure it is. it MAY just be a mistake because i don't know what pixel search wants. And "if $findnew > 1 then mouseclick" is all i could think of. I know that it most likely doesn't work like that. And i want it to loop the "if $findnew > 1 then mouseclick" part. Would a "While 1 <func here> Wend" do that? Can I have it in that same function i posted above?
newb_powa' Posted January 25, 2007 Posted January 25, 2007 (edited) try with If IsArray($Findnew) Then Mouseclick("left", $Findnew[0], $Findnew[1]) Edited January 25, 2007 by newb_powa'
alex OF DEATH Posted January 25, 2007 Author Posted January 25, 2007 If IsArray($Findnew) 1 Then Mouseclick("left", $Findnew[0], $Findnew[1]...^Error in expression
newb_powa' Posted January 25, 2007 Posted January 25, 2007 If IsArray($Findnew) Then Mouseclick("left", $Findnew[0], $Findnew[1] ...^ Error in expression I didn't remove the "1" ^^
alex OF DEATH Posted January 25, 2007 Author Posted January 25, 2007 No errors, but it doesn't click the color. I think i just need to loop it. while 1 Wend right?
newb_powa' Posted January 25, 2007 Posted January 25, 2007 No errors, but it doesn't click the color. I think i just need to loop it. while 1 Wend right? You're right, something like that should work Func go() ;Search for the color until it find it, then click it and exit loop $x = 0 Do $CurrentPos = MouseGetPos() $color = pixelgetcolor($CurrentPos[0] , $CurrentPos[1]) $Coord = PixelSearch(515, 255, 1030, 595, $color) If IsArray($Coord) Then MouseClick("Left", $Coord[0], $Coord[1], 1, 0) $x = 1 EndIf MouseMove($CurrentPos[0], $CurrentPos[1], 0) Until $x = 1 EndFunc If you want it to never stop to run, replace "Do" by "While 1" and "Until $x = 1" by "Wend"
Kohr Posted January 25, 2007 Posted January 25, 2007 Try this so you have an easy way to get out of this endless loop in case the color is not found. HotKeySet("{ESC}", "StopFunction") Global $x = 0 go() Func go() ;Search for the color until it find it, then click it and exit loop Do $CurrentPos = MouseGetPos() $color = PixelGetColor($CurrentPos[0], $CurrentPos[1]) $Coord = PixelSearch(515, 255, 1030, 595, $color) If IsArray($Coord) Then MouseClick("Left", $Coord[0], $Coord[1], 1, 0) ConsoleWrite("yes" & @CRLF) Return 1 EndIf MouseMove($CurrentPos[0], $CurrentPos[1], 0) Until $x = 1 ConsoleWrite("no" & @CRLF) Return 0 EndFunc ;==>go Func StopFunction() $x = 1 EndFunc ;==>StopFunction Kohr AutoIt LinksAutoIt CrapsGrid_PixelSearchAdvancedPixelGrab
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