newtoau3 Posted June 27, 2007 Share Posted June 27, 2007 Could somebody please show me how I would pixelsearch for a colour and then click on it? I know how to code the search and click bits but cant make them work Thanks. Link to comment Share on other sites More sharing options...
ofLight Posted June 27, 2007 Share Posted June 27, 2007 (edited) Sleep(3000) $pixel = 9626367 $xy = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$pixel);Searches entire desktop If @error Then MsgBox(0,"Error","Cant find that Pixel") Else MouseMove($xy[0],$xy[1], 30) MouseClick("Left",$xy[0],$xy[1]) EndIf Edited June 27, 2007 by ofLight There is always a butthead in the crowd, no matter how hard one tries to keep them out.......Volly Link to comment Share on other sites More sharing options...
newtoau3 Posted June 29, 2007 Author Share Posted June 29, 2007 Sleep(3000) $pixel = 9626367 $xy = PixelSearch(0,0,@DesktopWidth,@DesktopHeight,$pixel);Searches entire desktop If @error Then MsgBox(0,"Error","Cant find that Pixel") Else MouseMove($xy[0],$xy[1], 30) MouseClick("Left",$xy[0],$xy[1]) EndIf Thanks for your help ofLight. I've been using this to help me but now I have another problem.......anyone? I'm trying to make it wait until $ab = $pixel2 and then the subsequent clicks. Maybe the Until line is totally wrong?? Any help appreciated, thanks. $pixel2 = 0x959595 $ab = PixelSearch(1307,112,1309,114,$pixel2) Do Sleep(100) until ($ab[0] & $ab[1]) = ?????????; problem I think is this line..... Sleep(500) If @error Then MsgBox(0,"Error","Cant find that Pixel") Else MouseMove($ab[0],$ab[1]) sleep(500) MouseClick("left",$ab[0],$ab[1]) EndIf Link to comment Share on other sites More sharing options...
mikehunt114 Posted June 29, 2007 Share Posted June 29, 2007 (edited) I'm not certain what you're asking, but it looks like you want to keep searching for the color until it's found, then click it? The way your Do...Until statement was written, nothing was ever changing, all you were doing was sleeping Maybe something like this? $pixel2 = 0x959595 $ab = "" While Not IsArray($ab) $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2) Sleep(10) WEnd MsgBox(0, "", "Color found!") Sleep(500) MouseMove($ab[0], $ab[1]) sleep(500) MouseClick("left", $ab[0], $ab[1]) Edited June 29, 2007 by mikehunt114 IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
newtoau3 Posted June 30, 2007 Author Share Posted June 30, 2007 I'm not certain what you're asking, but it looks like you want to keep searching for the color until it's found, then click it? The way your Do...Until statement was written, nothing was ever changing, all you were doing was sleeping Maybe something like this? $pixel2 = 0x959595 $ab = "" While Not IsArray($ab) $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2) Sleep(10) WEnd MsgBox(0, "", "Color found!") Sleep(500) MouseMove($ab[0], $ab[1]) sleep(500) MouseClick("left", $ab[0], $ab[1])Thanks that worked great BUT I want to put a While/Wend around my whole script so that it'll repeat until there's no more 0xFFFF00. Here is the whole code.....can anyone please help? Thanks $pixel = 0xFFFF00 $xy = PixelSearch(1230,200,1232,280,$pixel) If not @error Then MouseMove($xy[0],$xy[1]) MouseClick("right",$xy[0],$xy[1]) Sleep(500) MouseClick("left", $xy[0] + Random(44,100), $xy[1] + 10 ) Sleep(2000) $pixel = 0xFFFF00 $xy = PixelSearch(1230,200,1232,280,$pixel) MouseClick("left",$xy[0],$xy[1]) Sleep(500) MouseMove(random(300,1210),Random(100,310)) EndIf $pixel2 = 0x959595 $ab = "" While Not IsArray($ab) $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2) Sleep(10) Wend Sleep(500) If @error Then MsgBox(0,"Error","Cant find that Pixel") Else MouseMove($ab[0],$ab[1]) sleep(500) MouseClick("left",$ab[0],$ab[1]) EndIf Link to comment Share on other sites More sharing options...
newtoau3 Posted June 30, 2007 Author Share Posted June 30, 2007 Thanks that worked great BUT I want to put a While/Wend around my whole script so that it'll repeat until there's no more 0xFFFF00. Here is the whole code.....can anyone please help? Thanks $pixel = 0xFFFF00 $xy = PixelSearch(1230,200,1232,280,$pixel) If not @error Then MouseMove($xy[0],$xy[1]) MouseClick("right",$xy[0],$xy[1]) Sleep(500) MouseClick("left", $xy[0] + Random(44,100), $xy[1] + 10 ) Sleep(2000) $pixel = 0xFFFF00 $xy = PixelSearch(1230,200,1232,280,$pixel) MouseClick("left",$xy[0],$xy[1]) Sleep(500) MouseMove(random(300,1210),Random(100,310)) EndIf $pixel2 = 0x959595 $ab = "" While Not IsArray($ab) $ab = PixelSearch(1307, 112 ,1309 ,114, $pixel2) Sleep(10) Wend Sleep(500) If @error Then MsgBox(0,"Error","Cant find that Pixel") Else MouseMove($ab[0],$ab[1]) sleep(500) MouseClick("left",$ab[0],$ab[1]) EndIfIs it possible to have a While/Wend around the whole thing seeing as though the While here reads "While not"? Or can I have only 1 While/Wend statement?? Anyhow I need it to repeat itself in a loop..... Link to comment Share on other sites More sharing options...
PsaltyDS Posted June 30, 2007 Share Posted June 30, 2007 Is it possible to have a While/Wend around the whole thing seeing as though the While here reads "While not"? Or can I have only 1 While/Wend statement?? Anyhow I need it to repeat itself in a loop.....You can nest While/WEnd, and other types of loops in AutoIt. Did you try it before asking...? 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...
newtoau3 Posted June 30, 2007 Author Share Posted June 30, 2007 Yes I did try it to no avail.... obviously I put it in the wrong place.....??? Link to comment Share on other sites More sharing options...
PsaltyDS Posted July 1, 2007 Share Posted July 1, 2007 Yes I did try it to no avail.... obviously I put it in the wrong place.....???I guess I'm missing something. Put While 1 at the top and WEnd at the bottom and the whole script will be looped indefinitely. What else was there? 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...
newtoau3 Posted July 1, 2007 Author Share Posted July 1, 2007 Hmmmm thats what I tried but had no luck - I kept getting a missing Wend message... Seems to be working now, dunno what was wrong...... Now to start tweaking abit..... Thanks Link to comment Share on other sites More sharing options...
mikehunt114 Posted July 3, 2007 Share Posted July 3, 2007 Could you clarify what you're trying to do? Maybe write out the steps you are trying to accomplish. IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
newtoau3 Posted July 9, 2007 Author Share Posted July 9, 2007 Ok got most of it going well but I'd like some help with 1 other bit plz. What it is supposed to do is: find yellow at a certain coord, click it. if it doesnt find it I want it to click elsewhere, opening a menu. Here's the script... its only part of the script but I'm having trouble with the 2nd case clause; tried if....else but still no luck. Why doesnt it work? Plz help. CODELocal $xy $pixel = 0xFFFF00 ;yellow colour $xy = PixelSearch(1230,200,1232,350,$pixel,2) While @error sleep(100) WEnd Select Case MouseMove($xy[0],$xy[1]) MouseClick("right",$xy[0],$xy[1]) Sleep(500) MouseClick("left", $xy[0] + Random(44,100), $xy[1] + 10 ) Sleep(2000) $pixel = 0xFFFF00 $xy = PixelSearch(1230,200,1232,280,$pixel) MouseClick("left",$xy[0],$xy[1]) Sleep(500) MouseMove(random(300,1210),Random(100,310)) Case $xy <> PixelSearch(1230,200,1232,350,$pixel,2) MouseClick("left",161,154) MouseClick("right",166,174) EndSelect Link to comment Share on other sites More sharing options...
mikehunt114 Posted July 9, 2007 Share Posted July 9, 2007 Your setup seems a little wonky to me....neither one of your Cases make much sense. How about using a simple If statement? HotKeySet("{ESC}", "Terminate") Local $xy $pixel = 0xFFFF00 ;yellow colour While 1 $xy = PixelSearch(1230,200,1232,350,$pixel,2) If IsArray($xy) Then ;$xy will be an array when the color is found ;click coords MouseClick("left", $xy[0], $xy[1], 1, 0) Else ;Click elsewhere....open a menu? EndIf WEnd Func Terminate() Exit 0 EndFunc IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font] Link to comment Share on other sites More sharing options...
newtoau3 Posted July 11, 2007 Author Share Posted July 11, 2007 Thanks Mike 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