Neversleep Posted May 17, 2012 Posted May 17, 2012 (edited) Hi all, it's my first post here and my second day using autoit (I've used it for some hours).I wanted to make a very simple first script: I just wanted autoit to click randomly in a rectangle and, between every click, it pauses from 5 to 10 seconds randomly. In the meantime it should check another area of the screen and search for a colour: if it finds it, it moves the cursor over it and clicks it, then continues clicking randomly and so on. Just let me show you with a picture: http://oi48.tinypic.com/2pqqaac.jpgThe code is:$i = 0Do ;starts a loop $coord = PixelSearch(101, 71, 729, 628, 0xFEFFD2) ; searches 0xFEFFD2 in a rectangle MouseClick("left", Random(817, 992, 1), Random(504, 609, 1), 1) ;clicks randomly in another area Sleep(Random(5000, 10000, 1)) ;waits from 5 to 10 seconds if not @error then MouseMove($coord[0],$coord[1],0) Sleep (3000) ;moves over the pixel and waits 3 seconds MouseClick("left",$coord[0],$coord[1]) Sleep (3000) ;clicks the pixel and waits 3 seconds EndIfUntil $i = 0I know you are veterans of autoit, but I added comments so that you can clearly understand what I wanted it to do. When I run the script it clicks once in the random click area and then a messagge appears saying subscript used with non-array value. I've searched it on the internet and on the forum, but I always get into scripts that are too much different from mine, and so I don't get how to solve this problem. Thanks a lot for the attention and sorry if my English isn't perfect Edited May 17, 2012 by Neversleep
Moderators JLogan3o13 Posted May 17, 2012 Moderators Posted May 17, 2012 Hi, neversleep, welcome to the forum. Can you clarify "click in a rectangle"? Is this searching the window of an application, or a rectangle you've drawn? If an application, what application are you trying to capture? There may be infinitely easier ways of accomplishing what you would like to do. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum!
Neversleep Posted May 17, 2012 Author Posted May 17, 2012 Thanks for the welcome and for the answer too The rectangles are "two pieces" of a window (Mozilla Firefox), and they are two: the bigger one is on the left side and is nearly a square, the second one is smaller and is located on the right bottom of the window
JohnOne Posted May 17, 2012 Posted May 17, 2012 (edited) Look where you have "if not @error then"It id checking to see if "Sleep(Random(5000, 10000, 1))"Try$i = 0Do ;starts a loop$coord = PixelSearch(101, 71, 729, 628, 0xFEFFD2) ; searches 0xFEFFD2 in a rectangle$error = @errorMouseClick("left", Random(817, 992, 1), Random(504, 609, 1), 1) ;clicks randomly in another areaSleep(Random(5000, 10000, 1)) ;waits from 5 to 10 secondsif not $error thenMouseMove($coord[0],$coord[1],0)Sleep (3000) ;moves over the pixel and waits 3 secondsMouseClick("left",$coord[0],$coord[1])Sleep (3000) ;clicks the pixel and waits 3 secondsEndIfUntil $i = 0EDIT:And of course, that loop will only run once since $i = 0 always Edited May 17, 2012 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
Neversleep Posted May 17, 2012 Author Posted May 17, 2012 @John: it doesn't work, it clicks once and then autoit closes
somdcomputerguy Posted May 17, 2012 Posted May 17, 2012 It does work. It does what it's told to do. Did you read JohnOnes' whole post? He did edit the post, but that was only 2 minutes after he made it. - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Neversleep Posted May 17, 2012 Author Posted May 17, 2012 No I didn't ! How do I make it last "forever" ?
somdcomputerguy Posted May 17, 2012 Posted May 17, 2012 While...WEnd - Bruce /*somdcomputerguy */ If you change the way you look at things, the things you look at change.
Neversleep Posted May 17, 2012 Author Posted May 17, 2012 (edited) Ok, now it works But it does not recognise the colour because it moves the mouse over wrong places...the colour I want it to click is kinda white, and for example it clicked in a black area two or three times (not three times in a row, but for free times)...tips ? Group of colours maybe ? Can I give autoit the order to click something that is very similar to a picture I want ? Edited May 17, 2012 by Neversleep
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