Lentil Posted May 29, 2013 Share Posted May 29, 2013 ; Find a pure lime green pixel or a green pixel within 10 shades variations of pure green $coord = PixelSearch( 0, 0, 20, 300, 0x32CD32, 10 ) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) EndIf I need this script modified to perform these actions 1. When the color is found, have script to begin again at a certain line 2. Get the script to pixel search every 30 seconds (if possible) So It'd running part 1 line 1-100 Part 2 would be the pixel search, but I'd like the script to return to line 1 once the color is found I'm sorry if this has been asked before. I'm trying to figure it out myself, but I'm having a hard time piecing everything together. Much appreciated. Link to comment Share on other sites More sharing options...
MouseSpotter Posted May 30, 2013 Share Posted May 30, 2013 Something like: While true DoSearch() wend Func DoSearch() local $coord = PixelSearch( 0, 0, 20, 300, 0x32CD32, 10 ) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) EndIf EndFunc Link to comment Share on other sites More sharing options...
Divine Posted May 30, 2013 Share Posted May 30, 2013 (edited) EDIT: It automatically makes the variable an array if it isn't so, that's why you are getting an error. Just fixing up MouseSpotter's code While true Call("DoSearch") WEnd Func DoSearch() Local $Coord = PixelSearch(0,0,20,300,0x32CD32,10) If IsArray($Coord) = True Then MsgBox(0,"X and Y are", $Coord[0] & "," & $Coord1) EndIf EndFunc Edited May 30, 2013 by Divine Link to comment Share on other sites More sharing options...
MouseSpotter Posted May 30, 2013 Share Posted May 30, 2013 Not so fast Oh mighty Divine. All I did was wrap a function around Lentil's code - which works fine and checks the @error code (a better option than checking for an array IMHO). BTW The Call statement is not required - I only use it for calling functions when I do not know if the function exists or not. While True DoSearch() WEnd Func DoSearch() Local $coord = PixelSearch(0, 0, 20, 300, 0x32CD32, 10) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) EndIf EndFunc Link to comment Share on other sites More sharing options...
Divine Posted May 30, 2013 Share Posted May 30, 2013 (edited) Not so fast Oh mighty Divine. All I did was wrap a function around Lentil's code - which works fine and checks the @error code (a better option than checking for an array IMHO). BTW The Call statement is not required - I only use it for calling functions when I do not know if the function exists or not. While True DoSearch() WEnd Func DoSearch() Local $coord = PixelSearch(0, 0, 20, 300, 0x32CD32, 10) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) EndIf EndFunc Very true, but I grew into the habit of Calling my function, looks better Anyway, to answer your question, I recommend creating two functions, one to part one, and another is part two. Func PART_ONE() ; Blah Blah Blah EndFunc Func PART_TWO() ;Aka DoSearch ; Blah Blah Blah, PixelSearch here. If you want the PixelSearch to keep repeating after 30 seconds, just put it ; in a separate function, slap a 30 second sleep on there, and call it here. I.E: _PixelSearch() EndFunc Func _PixelSearch() Sleep(30000) ; 30 second sleep! Local $coord = PixelSearch(0, 0, 20, 300, 0x32CD32, 10) If Not @error Then MsgBox(0, "X and Y are:", $coord[0] & "," & $coord[1]) Else MsgBox(0,"Error","Couldn't find the requested Pixel, :(.") EndIf EndFunc Edited May 30, 2013 by Divine Link to comment Share on other sites More sharing options...
Lentil Posted May 30, 2013 Author Share Posted May 30, 2013 Global $Paused, $counter = 0 HotKeySet("{PAUSE}", "TogglePause") HotKeySet("{delete}", "Terminate") HotKeySet("+!d", "ShowMessage") ;Shift-Alt-d While 1 sleep(2000) SEND("{k}") sleep(1050) MouseMove ( 486, 468) sleep(350) MouseClick("left") sleep(250) SEND("{esc}") sleep(250) SEND("{v}") sleep(5000) SEND("{v}") ;; ;; ;; ;; ;; MouseMove ( 825, 660) sleep(550) MouseClick("left") sleep(20550) MouseMove (62, 42) MouseClick("right") MouseMove (100, 90) MouseClick("left") sleep(5550) MouseClick("left") sleep(1550) WEnd ;;;;;;;; Func TogglePause() $Paused = NOT $Paused While $Paused sleep(100) ToolTip('Script is "Paused"',0,0, $counter, 1) WEnd ToolTip("") EndFunc Func Terminate() Exit 0 EndFunc Func ShowMessage() MsgBox(4096,"","This is a message.") EndFunc So this is what I'm using atm...I tried throwing it together with yours devine. I can't seem to get it to work. Sorry I'm really new at this...can you try to merge yours and mine and get part 1 to reset when the color is found? Also do I just throw the x n y coords of the color in there? or is it better to search an area? because the color I want to search for is about this size ============= Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 30, 2013 Moderators Share Posted May 30, 2013 Lentil, what application are you trying to manipulate? Judging by your code, there is probably a much easier way to do what you want to accomplish, without all of the MouseClicks, etc. "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! Link to comment Share on other sites More sharing options...
Bert Posted May 30, 2013 Share Posted May 30, 2013 agreed. What is the name of the application? Odds are there is a MUCH easier way to do what you have in mind as well as the code to do it may already be available so you don't have to reinvent the wheel. The Vollatran project My blog: http://www.vollysinterestingshit.com/ 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