mike1212 Posted March 13, 2005 Share Posted March 13, 2005 (edited) Hello I need a way to check for a pixel color change at a given location, x900 y 856 the color is normally 227359. The color will change to 1006484 at random this is when I need to mouseclick Left? I would like the mouse to click once then exit the loop but be ready when called upon. I used this code to no avail. While 1 $coord = PixelSearch( 0, 0, 90, 856, 1006484 ) If Not @error Then MouseClick ("left", $coord[0], $coord[1]) EndIf WEnd Func MyExit () Exit EndFunc TY Mike Edited March 13, 2005 by mike1212 Link to comment Share on other sites More sharing options...
WHRobin566 Posted March 13, 2005 Share Posted March 13, 2005 (edited) hmm ill try while 1 if pixelgetcolor(900, 856) = 1006484 Then Mouseclick("left", 900, 856) endif sleep(10) wend that will click where color changed i dont know if you want it to click there but if you dont then just erase the 900, 856 in mouseclick and leave it at "left" or you can put in new cords. Hope this helps. havn't tried it. Edited March 13, 2005 by WHRobin566 Witch Hunter Robin Link to comment Share on other sites More sharing options...
mike1212 Posted March 13, 2005 Author Share Posted March 13, 2005 (edited) hmm ill trywhile 1 if pixelgetcolor(900, 856) = 1006484 Then Mouseclick("left", 900, 856) endif sleep(10) wendthat will click where color changed i dont know if you want it to click there but if you dont then just erase the 900, 856 in mouseclick and leave it at "left" or you can put in new cords.Hope this helps. havn't tried it. <{POST_SNAPBACK}>That works great, however what is happening is it clicks when color changesand keeps going back to the x y location to click it again. I need it to click once when the pixel is correct, then exit the loop until the programtells it to look from it again.Getting close.Any Idea on this?Thanks Mike Edited March 13, 2005 by mike1212 Link to comment Share on other sites More sharing options...
quaizywabbit Posted March 13, 2005 Share Posted March 13, 2005 (edited) While Not PixelGetColor(900, 856) = 227359 checkpixelcolor() WEnd Func checkpixelcolor() If PixelGetColor(900, 856) = 1006484 Then $mouse = MouseGetPos() MouseClick("left", 900, 856, 0); 0= instantaneous move MouseMove($mouse[0],$mouse[1], 0); 0= instantaneous move EndIf EndFunc ;==>checkpixelcolor or While Not PixelGetColor(900, 856) = 227359 $mouse = MouseGetPos() MouseClick("left", 900, 856, 0); 0= instantaneous move MouseMove($mouse[0],$mouse[1], 0); 0=instantaneous move WEnd dunno if this is what you're after or not.....might need a Sleep() inserted in there edit....reread original post....added mouse return to original coordinates Edited March 13, 2005 by quaizywabbit [u]Do more with pre-existing apps![/u]ANYGUIv2.8 Link to comment Share on other sites More sharing options...
mike1212 Posted March 13, 2005 Author Share Posted March 13, 2005 (edited) While Not PixelGetColor(900, 856) = 227359 checkpixelcolor() WEnd Func checkpixelcolor() If PixelGetColor(900, 856) = 1006484 Then $mouse = MouseGetPos() MouseClick("left", 900, 856, 0); 0= instantaneous move MouseMove($mouse[0],$mouse[1], 0); 0= instantaneous move EndIf EndFunc ;==>checkpixelcolororWhile Not PixelGetColor(900, 856) = 227359 $mouse = MouseGetPos() MouseClick("left", 900, 856, 0); 0= instantaneous move MouseMove($mouse[0],$mouse[1], 0); 0=instantaneous move I guess what is happening is the script stays active in the loop. I need it to 1. wait til color changes 2. then click 3. then die. I dont know if a command statement of of WEnddunno if this is what you're after or not.....might need a Sleep() inserted in there edit....reread original post....added mouse return to original coordinates<{POST_SNAPBACK}>It looks like the script runs and clicks the color change when its present but when color change is not present it dies.I need it to 1. wait til color changes 2. then click 3. then die.4. the time delay needs to be random, a set sleep delay will not work.I think this is where the problem is.It needs to watch for the color change and when that happens, execute, then dieright away, so the next operation is not running with this one.Any Comments?TY Mike Edited March 13, 2005 by mike1212 Link to comment Share on other sites More sharing options...
quaizywabbit Posted March 13, 2005 Share Posted March 13, 2005 (edited) from what I understand so far, AutoIt isn't a multi-threaded language (i.e. It can't do 2 simultaneous operations) You can: put the rest of your script inside the while loop call "checkpixelcolor()" periodically at strategic points in your script(or just use adlib to call it periodically) Use it in a separate compiled script that runs only while your main script runs(this would create a separate thread, that won't interfere with the rest of your script.) because it is a random change, it needs to stay looped to detect the change and respond immediately. Beyond that, I'm at a loss cause' I don't know what exactly you're trying to make. Edited March 13, 2005 by quaizywabbit [u]Do more with pre-existing apps![/u]ANYGUIv2.8 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