scriptingishard2 Posted November 3, 2005 Share Posted November 3, 2005 (edited) I'm a total newbie using autoit. I was wondering if anyone could tell me how to fix this script so it functions the way I want it to. What I want this script to do is, continue in an infinite loop. What I want it to do is, look at a pixel I specify and if that pixel is a certain color I want it to do 1 left click on an x y corodinate that I specify. If that pixel is not that one particular color I want it to do nothing but move on to the next statement, and the next statement is the same kind of thing. Here is what I have so far, when I run this, it doesn't continue it just appears for 1/2 second in the tray and disappears, so obviously it's not going in a continual loop. That isn't the only thing, even when the pixel is the specified color it doesn't produce a click at all. I know I may have things in there that don't belong or I'm missing things I would need or the syntax is wrong. I would appreciate your help in fixing it to work properly. Func GetAction() $color = PixelGetColor (1470, 56); if $color = 20000 then MouseClick ( "left" [, 250, 480 [, 1 [, 10 ]]] ); return 1; endif $color = PixelGetColor (1470, 67); if $color = 70000 then MouseClick ( "left" [, 419, 574 [, 1 [, 10 ]]] ); return 2; endif $color = PixelGetColor (1470, 78); if $color = 80000 then MouseClick ( "left" [, 567, 476 [, 1 [, 10 ]]] ); return 3; endif $color = PixelGetColor (1470, 88); if $color = 40000 then MouseClick ( "left" [, 567, 476 [, 1 [, 10 ]]] ); return 4; endif return 1; EndFunc I see that people have looked at my thread yet no one has posted anything. Let me know if you need any more information, or if you just wouldn't know how to do what I'm looking for this script to do, that way I at least know where you guys are that are reading this post, thanks. If you would like a drawing of what I'm talking about I could make one. Edited November 3, 2005 by scriptingishard2 Link to comment Share on other sites More sharing options...
scriptingishard2 Posted November 4, 2005 Author Share Posted November 4, 2005 I figured out some things, I fixed some of the script so that it now appears to do what it's supposed to do for the most part, now the only part I need help with is how to get it into an infinite loop. How do I set it up so my script just keeps running over and over without stopping? Link to comment Share on other sites More sharing options...
Valuater Posted November 4, 2005 Share Posted November 4, 2005 maybe like this ; Press Esc to terminate script HotKeySet("{ESC}", "Terminate") ;;;; Body of program would go here;;;; While 1 GetAction() Sleep(10) WEnd ;;;;;;;; Func Terminate() Exit 0 EndFunc Func GetAction() ; Your ; Script ; Here EndFunc 8) Link to comment Share on other sites More sharing options...
scriptingishard2 Posted November 4, 2005 Author Share Posted November 4, 2005 (edited) Nope that didn't work. What that did is, if it doesn't find any of the pixel colors it was looking for, it will stay in the tray but even if those colors come up, it won't do anything, it just stays in the tray until you exit it. If you run it and it does find the one of the colors it's looking for right away then it will do it's one action and then it will quit, and I don't want it to do that, even if it finds the color and does the action I want it to stay running so it will continue to work. This is what it looks like with the code you suggested added. ; Press Esc to terminate script HotKeySet("{ESC}", "Terminate") $color = PixelGetColor( 1470 , 56 ) if $color = 40000 then MouseClick("left", 250, 480, 1, 10) return 1; endif $color = PixelGetColor( 1470 , 67 ) if $color = 50000 then MouseClick("left", 429, 477, 1, 10) return 2; endif $color = PixelGetColor( 1470, 78 ) if $color = 60000 then MouseClick("left", 567, 476, 1, 10) return 3; endif $color = PixelGetColor ( 1470, 88 ) if $color = 70000 then MouseClick("left", 567, 476, 1, 10) return 4; endif While 1 GetAction() Sleep(10) WEnd ;;;;;;;; Func Terminate() Exit 0 EndFunc Func GetAction() ; Your ; Script ; Here EndFunc Now it could be that I have some code in there that is telling it to end, if there is some replacement code or something else I can do to keep it running though the script that would be cool. Thanks for your reply's hope to keep hearing from you guys. Edited November 4, 2005 by scriptingishard2 Link to comment Share on other sites More sharing options...
Nuffilein805 Posted November 4, 2005 Share Posted November 4, 2005 what did you do? it should be HotKeySet("{ESC}", "Terminate") While 1 $a = GetAction() ;msgbox(0, "Returnvalue", $a) Sleep(10) WEnd ;;;;;;;; Func Terminate() Exit 0 EndFunc Func GetAction() $color = PixelGetColor( 1470 , 56 ) if $color = 40000 then MouseClick("left", 250, 480, 1, 10) return 1; endif $color = PixelGetColor( 1470 , 67 ) if $color = 50000 then MouseClick("left", 429, 477, 1, 10) return 2; endif $color = PixelGetColor( 1470, 78 ) if $color = 60000 then MouseClick("left", 567, 476, 1, 10) return 3; endif $color = PixelGetColor ( 1470, 88 ) if $color = 70000 then MouseClick("left", 567, 476, 1, 10) return 4; endif EndFunc for what do you need the return-values? my little chatmy little encryption toolmy little hidermy unsafe clickbot Link to comment Share on other sites More sharing options...
scriptingishard2 Posted November 4, 2005 Author Share Posted November 4, 2005 Thanks, that works. I'm such a noob I don't even know why the return values are there. I guess the only other thing is, using your way of making it go into a loop, is there a way to add pauses between each action? Like 2 seconds for each using the sleep command? So that I could move the mouse for 2 seconds before it goes to the next function? Link to comment Share on other sites More sharing options...
Nuffilein805 Posted November 4, 2005 Share Posted November 4, 2005 sure there is: HotKeySet("{ESC}", "Terminate") hotkeyset("{pause}", "Pausemefast") While 1 GetAction() Sleep(2000);here is your sleep - just increase if you need more time WEnd ;;;;;;;; Func Terminate() Exit 0 EndFunc Func GetAction() $color = PixelGetColor( 1470 , 56 ) if $color = 40000 then MouseClick("left", 250, 480, 1, 10) endif $color = PixelGetColor( 1470 , 67 ) if $color = 50000 then MouseClick("left", 429, 477, 1, 10) endif $color = PixelGetColor( 1470, 78 ) if $color = 60000 then MouseClick("left", 567, 476, 1, 10) endif $color = PixelGetColor ( 1470, 88 ) if $color = 70000 then MouseClick("left", 567, 476, 1, 10) endif EndFunc func Pausemefast() sleep (10000) endfunc if you hit {pause} you get an additional sleep of 10 secs my little chatmy little encryption toolmy little hidermy unsafe clickbot 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