Jump to content

Looping Troubles


Recommended Posts

WinWaitActive("WindowName")
sleep(100)
$var1 = PixelGetColor(16, 350) ;Green var1=0x00C000, Gray =0xECE9D8, Yellow = 0xC0C000, Red = 0xC00000
$var2 = PixelGetColor(140, 371) ; High var2 = 0x7C4A1C
$var3 = PixelGetColor(765, 543) ; Blank = 0xCCC2AC, Grass = 0x516002, = 0x00C000
$Queue = PixelGetColor(76, 384) ;Queue 76, 384 ;Gray= 0xECE9D8, Red = 0xC00000



Func var1()
    MouseClick("left", 763, 547, 1, 0)
    Sleep(5000)
EndFunc

Func var2()
    MouseClick("left", 624, 66, 1, 0)
EndFunc


Func var3()
    send("3")
    sleep(300)
    send("e")
    sleep(5000)
    send("e")
    sleep(5000)
    send("e")
    sleep(5000)
    send("e")
    sleep(5000) 
    send("1")
    sleep (300)
EndFunc

Func MoveLeft()
    Send("{left}")
EndFunc

Func MoveRight()
    Send("{right}")
EndFunc

Func MoveDown()
    Send("{down}")
EndFunc

Func MoveUp()
    send("{up}")
EndFunc

Func FindRow()
    $NextRowLeft = PixelGetColor(675, 609)
    $NextRowRight = PixelGetColor(807, 600)
    If $NextRowLeft = 0x8B1017 Then
        MouseClick("Left", 675, 609, 1, 0)
    ElseIf $NextRowRight = 0x4F1611 Then
        MouseClick("left", 807, 600, 1, 0)
EndIf       
EndFunc
while 1=1
$var1 = PixelGetColor(16, 350) ;Green var1=0x00C000, Gray =0xECE9D8, Yellow = 0xC0C000, Red = 0xC00000
$var2 = PixelGetColor(140, 371) ; High var2 = 0x7C4A1C
$var3 = PixelGetColor(765, 543) ; Blank = 0xCCC2AC, = 0x8F1923, = 0x4C4634
$Queue = PixelGetColor(76, 384) ; Queue 76, 384 ;Gray= 0xECE9D8, Red = 0xC00000
If $var1 = 0x00C000 And $var2 = 0xECE9D8 And $Queue = 0xECE9D8 And $var3 = 0xAB1525 Then
        Call("var1")
ElseIf $var1 = 0x00C000 And $var2 = 0xECE9D8 And $Queue = 0xECE9D8 And $var3 = 0xCCBEA4 Then
        Call("MoveRight")
        sleep(1000) 
    ElseIf $var1 = 0x00C000 And $var2 = 0xECE9D8 And $Queue = 0xECE9D8 And $var3 = 0x516002 Then
        Call("FindRow")
        sleep(1000)
    ElseIf $var1 = 0xC00000 And $var2 = 0xECE9D8 And $Queue = 0xECE9D8 Then
        Call("var3")
    Else
EndIf
WEnd

The problem I'm having occurs after it executes "func var1". It is supposed to make a left-mouse click and then wait for five seconds, which it does just fine. However, it then executes that same function again, as if it's not updating the color variables quite quick enough and it still believes that all of the conditions needed to run "func var1" are true(When in reality, it SHOULD go on to do one of the "elseif" commands, such as call one of my other functions(MoveRight).

Link to comment
Share on other sites

Hello rushpanther,

First, Welcome to the AutoIt Forums :graduated:

Second, Your code structure is all wrong. Please take this as constructive criticism.

Custom Functions should be placed last in your script. Functions do not run unless they are called.

_RunMyFunction()

Func _RunMyFunction()
     MsgBox(0,'Say Hello','Hello')
EndFunc

What I suggest is spending some time reading the 'Help File' and taking part in some tutorials. There are many tutorials on You Tube along with a Tutorial built in AutoIt in Example section of the Forums called: '

I know you just want to jump right into it, but this is one of those things in life that pay doing the studying first. It will save you time, and us as well.

Realm

P.S. Please do not bump your posts within 24 hours in future. This is not a 24/7 support forum - those who answer are only here because they like helping others and have some time to spare. You just have to wait until someone who knows something about your particular problem, and is willing to help, comes online. Be patient and someone will answer eventually.

My Contributions: Unix Timestamp: Calculate Unix time, or seconds since Epoch, accounting for your local timezone and daylight savings time. RegEdit Jumper: A Small & Simple interface based on Yashied's Reg Jumper Function, for searching Hives in your registry. 

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...