Bliz0r Posted July 24, 2007 Share Posted July 24, 2007 Hello. I'm trying to make it detect a color and then click it. Always searching for it, and click on it on when it pops up. $Loop = 0 While $Loop = 0 If $SearchResult = PixelSearch ($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then Mouseclick ("Primary", $SearchResult, $SearchResult, 10, 0) Sleep(1000) If $Loop = 1 Then ContinueLoop WEnd What's wrong with that code? It never clicks the color when it pops up. Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 24, 2007 Share Posted July 24, 2007 Hello. I'm trying to make it detect a color and then click it. Always searching for it, and click on it on when it pops up. $Loop = 0 While $Loop = 0 If $SearchResult = PixelSearch ($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) Then Mouseclick ("Primary", $SearchResult, $SearchResult, 10, 0) Sleep(1000) If $Loop = 1 Then ContinueLoop WEnd What's wrong with that code? It never clicks the color when it pops up. Read the help file. PixelSearch() returns an array, which will be $SearchResult. If you try to make a numeric compare with an entire array it is always 0, so your If statement is never true. Try: While 1 $SearchResult = PixelSearch ($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) If Not @error Then Mouseclick ("Primary", $SearchResult[0], $SearchResult[1], 10, 0) Sleep(20); avoid spiking CPU WEnd Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
Bliz0r Posted July 24, 2007 Author Share Posted July 24, 2007 Read the help file. PixelSearch() returns an array, which will be $SearchResult. If you try to make a numeric compare with an entire array it is always 0, so your If statement is never true. Try: While 1 $SearchResult = PixelSearch ($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) If Not @error Then Mouseclick ("Primary", $SearchResult[0], $SearchResult[1], 10, 0) Sleep(20); avoid spiking CPU WEnd Still didnt change anything, still didnt click? :s Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 24, 2007 Share Posted July 24, 2007 Still didnt change anything, still didnt click? :s Works fine for me, what are you using for inputs...? Dim $Hoejre = 0, $Toppen = 0, $Venstre = 50, $Bunden = 50, $Farve = 0xFFFFFF HotKeySet("{ESC}", "_Quit") While 1 $SearchResult = PixelSearch($Hoejre, $Toppen, $Venstre, $Bunden, $Farve) If Not @error Then MouseClick("Primary", $SearchResult[0], $SearchResult[1], 10, 0) Sleep(20); avoid spiking CPU WEnd Func _Quit() Exit EndFunc ;==>_Quit Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
qazwsx Posted July 24, 2007 Share Posted July 24, 2007 put in a msgbox to see if the color is being found. Link to comment Share on other sites More sharing options...
Bliz0r Posted July 24, 2007 Author Share Posted July 24, 2007 The input variables:$Farve = 0xFFCC66 $Hoejre = 406 $Toppen = 21 $Venstre = 30 $Bunden = 372Ill add a picture of the situation: Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 24, 2007 Share Posted July 24, 2007 The input variables: $Farve = 0xFFCC66 $Hoejre = 406 $Toppen = 21 $Venstre = 30 $Bunden = 372 Ill add a picture of the situation: You have confused the coordinates. Re-read the help file on PixelSearch() and look at the order you are giving the coordinates. The first two parameters are X,Y of the top/left (that would be your AutoIt-left) corner of the search box. The next two parameters are the X'/Y' of the bottom/right corner. Your numbers don't make sense. Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law 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