tigolbitties Posted June 5, 2011 Share Posted June 5, 2011 I'm trying to write a simple program click on specific colors on my active window. When I use pixelsearch all that happens is the mouse goes to the top left of my screen and clicks. please help, I have already browsed the forums and several other webpages but cannot find a simple solution. Here's my simple code: $i = 0 While $i < 5 ; number of clicks until script stops $coords = pixelsearch (544, 419, 716, 436, 0xCCB63A, 10, 0) if not @error then MouseClick("left", $coords, $coords, 1) endif $i = $i + 1 WEnd Link to comment Share on other sites More sharing options...
jvanegmond Posted June 5, 2011 Share Posted June 5, 2011 (edited) MouseClick("left", $coords[0], $coords[1], 1) ;runescape Edited June 5, 2011 by Manadar github.com/jvanegmond Link to comment Share on other sites More sharing options...
tigolbitties Posted June 5, 2011 Author Share Posted June 5, 2011 MouseClick("left", $coords[0], $coords[1], 1) ;runescape Thank you for your help, but can you please explain what that [0] and [1] actually mean? x=0 and y=1 ? Link to comment Share on other sites More sharing options...
Fubarable Posted June 5, 2011 Share Posted June 5, 2011 Thank you for your help, but can you please explain what that [0] and [1] actually mean? x=0 and y=1 ? Check out the AutoIt help file on the PixelSearch function. There you'll see that if successful, it returns an array that here is being placed into the $coords variable. The x location is placed in the 0 item in the array and the y location in the 1 item in the array (which is actually the second item in the array since arrays are 0 based). You might want to test this out by printing out $coord[0] and $coord[1] to the console inside of your if block by using the ConsoleWrite function. What is the goal of your little application by the way? Link to comment Share on other sites More sharing options...
BitByteBit Posted June 5, 2011 Share Posted June 5, 2011 Hope this helps.#include<array.au3> ;Only needed to use _ArrayDisplay! Global $Array[4] $Array[0] = 'This' $Array[1] = 'is' $Array[2] = 'an' $Array[3] = 'array.' _ArrayDisplay($Array) ;Print elements 0 through to 3. For $i = 0 To 3 ConsoleWrite($Array[$i] & @CRLF) Nexthttp://www.autoitscript.com/wiki/Arrays Link to comment Share on other sites More sharing options...
hotbuttmud Posted June 5, 2011 Share Posted June 5, 2011 I'd add 1 to $i within the if statement, because even if PixelSearch doesn't find it, it will still add 1 to $i during the cycle, like this:$i = 0 While $i < 5 $coords = pixelsearch (544, 419, 716, 436, 0xCCB63A, 10, 0) if not @error then MouseClick("left", $coords, $coords, 1) $i = $i + 1 endif WEnd Link to comment Share on other sites More sharing options...
Rogue5099 Posted June 5, 2011 Share Posted June 5, 2011 (edited) I'd add 1 to $i within the if statement, because even if PixelSearch doesn't find it, it will still add 1 to $i during the cycle, like this: $i = 0 While $i < 5 $coords = pixelsearch (544, 419, 716, 436, 0xCCB63A, 10, 0) if not @error then MouseClick("left", $coords, $coords, 1) $i = $i + 1 endif WEnd With this above the while statement will end in millisecondes if you dont get a syntax error first. Correct Usage: $i = 0 While $i < 5 $coords = PixelSearch(544, 419, 716, 436, 0xCCB63A, 10, 0) If Not @error Then MouseClick("left", $coords[0], $coords[1], 1) $i = $i + 1 EndIf WEnd Edited June 5, 2011 by rogue5099 My projects: Inventory / Mp3 Inventory, Computer Stats Link to comment Share on other sites More sharing options...
jvanegmond Posted June 6, 2011 Share Posted June 6, 2011 What is the goal of your little application by the way?It's part of a Runescape bot. github.com/jvanegmond 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