Sign in to follow this  
Followers 0
kazhkaz

If color... :)

29 posts in this topic

hello again :) i am writing some script and i have one problem :S i dont know how to write if sentence :P 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 :lmao: can u helpm me plz? :( thanks :)

Share this post


Link to post
Share on other sites



and one more thing :P what command should i use that script will repeat everything from the begining ? :lmao:

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

hello again :) i am writing some script and i have one problem :S i dont know how to write if sentence :P 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 :lmao: 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 by BigDod


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

thanks :P 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 () :lmao: 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

Share this post


Link to post
Share on other sites

some1 plz help me :P i cant wait. Want to end my first script :lmao:

Share this post


Link to post
Share on other sites

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)

Share this post


Link to post
Share on other sites

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.


[center]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.[/center]

Share this post


Link to post
Share on other sites

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)
    EndIF
if 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


1100111 00001011101111 00011101101111 00010111100100 00001111110100 00110111110010 00101101111001 0011100i didn't make up this form of encryption, but i like it.credit to the lvl 6 challenge on arcanum.co.nz

Share this post


Link to post
Share on other sites

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.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

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

Share this post


Link to post
Share on other sites

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.

[center]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.[/center]

Share this post


Link to post
Share on other sites

thanks for helping :P can u explain me with while and Wend :lmao: 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 :lmao:

this is my whole script :( dont look at Do...Until becose i tried smth :king:

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)

Share this post


Link to post
Share on other sites

; 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


[center]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.[/center]

Share this post


Link to post
Share on other sites

i think that will be ok :P 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? :lmao:

Share this post


Link to post
Share on other sites

#14 ·  Posted (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 by SmOke_N

[center]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.[/center]

Share this post


Link to post
Share on other sites

when its Until PixelGetColor(279, 207) == 0x674023 Then

and does to mouse click i need that it end the script :P i wanted that it reapeat all the script till Until PixelGetColor(279, 207) == 0x674023 Then :lmao: i hope u understand :(

Share this post


Link to post
Share on other sites

Then just remove: While 1 and Wend


[center]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.[/center]

Share this post


Link to post
Share on other sites

your script worked :P 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 :lmao: now it clicks enter :)

Share this post


Link to post
Share on other sites

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?


[center]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.[/center]

Share this post


Link to post
Share on other sites

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 :P

Share this post


Link to post
Share on other sites

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?


[center]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.[/center]

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0