kazhkaz Posted January 3, 2006 Share Posted January 3, 2006 hello again i am writing some script and i have one problem :S i dont know how to write if sentence i want that the mouse move to a place, and then if color is red(for example) do one command, if not do other command can u helpm me plz? thanks Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 and one more thing what command should i use that script will repeat everything from the begining ? Link to comment Share on other sites More sharing options...
BigDod Posted January 3, 2006 Share Posted January 3, 2006 (edited) hello again i am writing some script and i have one problem :S i dont know how to write if sentence i want that the mouse move to a place, and then if color is red(for example) do one command, if not do other command can u helpm me plz? thanks if PixelGetColor(500,500) = 0xFF0000 Then MsgBox(0,"","The pixel is red") Else MsgBox(0,"","The pixel is not red") EndIf If you know the coordinate where you want to check it is not necessary to move the mouse to it. Edit The answer to your second question is to place it inside a loop. Edited January 3, 2006 by BigDod Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 thanks i want to ask how to make own commands(i dont know how to name it ) for example : go = mouseclick(), what should i write, that later in commands write go , but not mouseclick () and another question where should i put Loop that script will repeat only if sentense is right heres my script : Run("C:\Program Files\Silkroad\Silkroad.exe") WinWaitActive("Silkroad Online Launcher") Sleep(10000) MouseClick("left", 756, 510) WinWaitActive("SRO_Client") Sleep(5000) Send("{ENTER}") Send("user", 3) Send("{TAB}") Sleep(500) Send("pass") Send("{ENTER}") Sleep(5000) MouseMove(512, 428) If PixelGetColor( 512, 428) Then MouseClick("left", 512, 428) EndIF Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 some1 plz help me i cant wait. Want to end my first script Link to comment Share on other sites More sharing options...
Oxin8 Posted January 3, 2006 Share Posted January 3, 2006 the kind of loop you're looking for is a While loop While 1;condition is true. this loop is infinite cuz 1 is always true ;Do Stuff WEnd that's pretty basic stuff so you might want to read through the help file and check out alex's tut (http://www.autoitscript.com/forum/index.php?showtopic=19434) ~My Scripts~ *********_XInput UDF for Xbox 360 ControllerSprayPaint_MouseMovePlus Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 3, 2006 Moderators Share Posted January 3, 2006 Errr... did no one catch this? If PixelGetColor( 512, 428) Then MouseClick("left", 512, 428) EndIF If PixelGetColor() == What? P.S. The MouseMove is redundant, unless your trying to get a color under the mouse, the PixelGetColor() gets the color at the location you specified. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
seandisanti Posted January 3, 2006 Share Posted January 3, 2006 for example : go = mouseclick(), what should i write, that later in commands write go , but not mouseclick ()Run("C:\Program Files\Silkroad\Silkroad.exe") WinWaitActive("Silkroad Online Launcher") Sleep(10000) MouseClick("left", 756, 510) WinWaitActive("SRO_Client") Sleep(5000) Send("{ENTER}") Send("user", 3) Send("{TAB}") Sleep(500) Send("pass") Send("{ENTER}") Sleep(5000) MouseMove(512, 428) If PixelGetColor( 512, 428) Then MouseClick("left", 512, 428) EndIFif you're trying to alias default functions, that's actually like creating simple UDF's. for the example given: Func Go ($x,$y,$speed = 0) MouseMove($x,$y,$speed) EndFunc check out udf's in the helpfile for more explanation Link to comment Share on other sites More sharing options...
BigDod Posted January 3, 2006 Share Posted January 3, 2006 Errr... did no one catch this? If PixelGetColor( 512, 428) Then MouseClick("left", 512, 428) EndIF If PixelGetColor() == What?My example had the PixelGetColor() = 0xFF0000 so I was assuming that he had just made a typo in his haste for an answer. Time you enjoyed wasting is not wasted time ......T.S. Elliot Suspense is worse than disappointment................Robert Burns God help the man who won't help himself, because no-one else will...........My Grandmother Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 3, 2006 Moderators Share Posted January 3, 2006 My example had the PixelGetColor() = 0xFF0000 so I was assuming that he had just made a typo in his haste for an answer.Yeh, I saw that just now... didn't put an edit up there ( a bit lazy today ) lol. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 thanks for helping can u explain me with while and Wend becose i cant open pdf file where i should put whil end WEnd that it will reapeat clicking enter until this sentence is right : If PixelGetColor( 512, 428) = 0x9C4A31 Then MouseClick("left", 512, 428) else Send("{ENTER}") and then it start script from the beggining sorry for my bad english but i hope u will understand what i want this is my whole script dont look at Do...Until becose i tried smth Do Run("C:\Program Files\Silkroad\Silkroad.exe") WinWaitActive("Silkroad Online Launcher") Sleep(10000) MouseClick("left", 756, 510) WinWaitActive("SRO_Client") Sleep(10000) Send("{ENTER}") Sleep (1000) Send("user", 3) Send("{TAB}") Sleep(500) Send("pass") Send("{ENTER}") Sleep(10000) MouseMove( 512. 428) If PixelGetColor( 512, 428) = 0x9C4A31 Then MouseClick("left", 512, 428) else Send("{ENTER}") EndIF Sleep(5000) Until PixelGetColor(279, 207) = 0x674023 Then MouseClick("left", 332, 372) MouseClick("left", 861, 704) Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 3, 2006 Moderators Share Posted January 3, 2006 ; how did you get your coords from the autoinfo tool, are they screen coords / window coords / or client coords ; the below OPT's will use window coords as an example the 0 indentifies window in the OPT's I'm using Opt("MouseCoordMode", 0); read the help to see if you need to change that to a 1 or 2 if it's 1, I suggest your reget your coords with window or client Opt("PixelCoordMode", 0) Opt("WinTitleMatchMode", 2); Just in case... let's make sure that if we don't have the whole title, that it finds the window all the same While 1; starting of an infinite loop If Not ProcessExists('Silkroad.exe') Then Run("C:\Program Files\Silkroad\Silkroad.exe") EndIf WinWait("Silkroad Online Launcher"); wait 3 seconds for the window to exist If Not WinActive("SilkRoad Online Launcher") Then WinActivate("SilkRoad Online Launcher"); activate if not active once window exists.. this ensures that if the window was blocked by somthing else that it will get activated EndIf Sleep(10000) MouseClick("left", 756, 510, 1, 1) WinWaitActive("SRO_Client") Sleep(10000) Send("{ENTER}") Sleep (1000) Send("user", 3) Send("{TAB}") Sleep(500) Send("pass") Send("{ENTER}") Sleep(10000) Do; will do the pixelgetcolor every 5 seconds until it = 0x674023 If PixelGetColor( 512, 428) == 0x9C4A31 Then MouseClick("left", 512, 428, 1, 1); added a 1 for 1 click, and 1 for speed Else Send("{ENTER}") EndIF Sleep(5000) Until PixelGetColor(279, 207) == 0x674023 Then MouseClick("left", 332, 372, 1, 1) MouseClick("left", 861, 704, 1, 1) WEnd;going back to the beginning of While 1 Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 i think that will be ok i want to ask u smth Else Send("{ENTER}") EndIF Sleep(5000) Until PixelGetColor(279, 207) == 0x674023 Then MouseClick("left", 332, 372, 1, 1) i wanted that it will wait 5 seconds before looking that PixelGetColor(279, 207) == 0x674023 is it written good? Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 3, 2006 Moderators Share Posted January 3, 2006 (edited) After it checks to see if PixelGetColor( 512, 428) == 0x9C4A31 then it will wait 5 seconds, check PixelGetColor(279, 207) == 0x674023 .. if that is true (the PixelGetColor(279, 207) == 0x674023 and it does == 0x674023) then it will exit that loop, do your other 2 mouseclicks, and then start all over. Edit: By the way: Send("user", 3) <<< what is the 3, that is an optional flag area you have that in, and it can only be 0 or 1. Edit 2: You'll see a comment in my snippet I put up there ; ; wait 3 seconds for the window to exist (I changed that when I added the If/Then Statement. Edited January 3, 2006 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 when its Until PixelGetColor(279, 207) == 0x674023 Then and does to mouse click i need that it end the script i wanted that it reapeat all the script till Until PixelGetColor(279, 207) == 0x674023 Then i hope u understand Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 3, 2006 Moderators Share Posted January 3, 2006 Then just remove: While 1 and Wend Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 your script worked thanks i made some changes everything works but after If PixelGetColor( 512, 428) == 0x9C4A31 Then MouseClick("left", 512, 428, 1, 1) i want that the script go from the beggining now it clicks enter Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 3, 2006 Moderators Share Posted January 3, 2006 Hmm... I don't know whether to say great.. it works, or to say what do you mean...? Did you get the desired affect you were looking for? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
kazhkaz Posted January 3, 2006 Author Share Posted January 3, 2006 everything is fine except : when PixelGetColor( 512, 428) == 0x9C4A31 MouseClick("left", 512, 428, 1, 1) else Send("{ENTER}") i want after mouse click the script would start from the beggining, but when it is true: PixelGetColor( 512, 428) == 0x9C4A31 it will press enter Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted January 3, 2006 Moderators Share Posted January 3, 2006 Beginning of what? The very beginning of your Do/Until Loop ... or the Very beginning of everything you did to get to your Do/Until Loop? Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. 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