Jump to content

While inside while


Recommended Posts

I am so confused as to what is causing the error.

Any help would be great.

Thanks.

<!--c1--><div class='codetop'>CODE</div><div class='codemain'><!--ec1-->
AutoItSetOption("PixelCoordMode",0)
AutoItSetOption("MouseCoordMode",0)
HotKeySet("{ESC}","Terminate")
While 0=0
    Func Terminate()
        Exit 0
    EndFunc
    Dim $y=0
    WinActivate("url")
    WinWaitActive("url")
    MouseClick("",400,440)
    Sleep(5000)
    MouseClick("",600,585)
    Sleep(5000)
    MouseClick("",1055,370)
    While $y < 531
        Dim $y=Random(310,530,1)
        WinActivate ("url")
        If WinActive ("url")Then 
            MouseClick("",58,$y,1,0)
            MouseClick("",500,299,1,0)
        EndIf
        If PixelGetColor(577,315)=9925823 Then
            Do
                $y=Random(310,530,1)
                MouseClick("",58,$y,1,0)
            Until PixelGetColor(577,315)=16777215
            MouseClick("",500,299,1,0)
        EndIf
        sleep(2000)
        If PixelGetColor(35,495)=15066597 Then
            MouseWheel("down",10)
            MouseClick("",297,490)
        EndIf
    WEnd
WEnd
<!--c2--></div><!--ec2-->
Link to comment
Share on other sites

  • Moderators

You have the whole function

Func Terminate()
        Exit 0
    EndFuncoÝ÷ Û­)íå¡W¥¢j}ý¶¯yéí·ºw-ðØb§(Ø­ÚÇ­¶)àjëh×6
AutoItSetOption("PixelCoordMode",0)
AutoItSetOption("MouseCoordMode",0)
HotKeySet("{ESC}","Terminate")
While 0=0
    Dim $y=0
    WinActivate("url")
    WinWaitActive("url")
    MouseClick("",400,440)
    Sleep(5000)
    MouseClick("",600,585)
    Sleep(5000)
    MouseClick("",1055,370)
    While $y < 531
        Dim $y=Random(310,530,1)
        WinActivate ("url")
        If WinActive ("url")Then
            MouseClick("",58,$y,1,0)
            MouseClick("",500,299,1,0)
        EndIf
        If PixelGetColor(577,315)=9925823 Then
            Do
                $y=Random(310,530,1)
                MouseClick("",58,$y,1,0)
            Until PixelGetColor(577,315)=16777215
            MouseClick("",500,299,1,0)
        EndIf
        sleep(2000)
        If PixelGetColor(35,495)=15066597 Then
            MouseWheel("down",10)
            MouseClick("",297,490)
        EndIf
    WEnd
WEnd

Func Terminate()
    Exit 0
EndFunc
I only glanced, didn't bother to look at the rest.

Edited 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

You've got some other problems too. This actually compiles, but I have no idea what you were trying to do:

AutoItSetOption("PixelCoordMode",0)
AutoItSetOption("MouseCoordMode",0)
HotKeySet("{ESC}","Terminate")
While 0=0
    Dim $y=0
    WinActivate("url")
    WinWaitActive("url")
    MouseClick("left",400,440)
    Sleep(5000)
    MouseClick("left",600,585)
    Sleep(5000)
    MouseClick("left",1055,370)
    While $y < 531
        Dim $y=Random(310,530,1)
        WinActivate ("url")
        If WinActive ("url")Then
            MouseClick("left",58,$y,1,0)
            MouseClick("left",500,299,1,0)
        EndIf
        If PixelGetColor(577,315)=9925823 Then
            Do
                $y=Random(310,530,1)
                MouseClick("left",58,$y,1,0)
            Until PixelGetColor(577,315)=16777215
            MouseClick("left",500,299,1,0)
        EndIf
        sleep(2000)
        If PixelGetColor(35,495)=15066597 Then
            MouseWheel("down",10)
            MouseClick("left",297,490)
        EndIf
    WEnd
WEnd

Func Terminate()
  Exit 0
EndFunc
Auto3Lib: A library of over 1200 functions for AutoIt
Link to comment
Share on other sites

You've got some other problems too. This actually compiles, but I have no idea what you were trying to do:

AutoItSetOption("PixelCoordMode",0)
AutoItSetOption("MouseCoordMode",0)
HotKeySet("{ESC}","Terminate")
While 0=0
    Dim $y=0
    WinActivate("url")
    WinWaitActive("url")
    MouseClick("left",400,440)
    Sleep(5000)
    MouseClick("left",600,585)
    Sleep(5000)
    MouseClick("left",1055,370)
    While $y < 531
        Dim $y=Random(310,530,1)
        WinActivate ("url")
        If WinActive ("url")Then
            MouseClick("left",58,$y,1,0)
            MouseClick("left",500,299,1,0)
        EndIf
        If PixelGetColor(577,315)=9925823 Then
            Do
                $y=Random(310,530,1)
                MouseClick("left",58,$y,1,0)
            Until PixelGetColor(577,315)=16777215
            MouseClick("left",500,299,1,0)
        EndIf
        sleep(2000)
        If PixelGetColor(35,495)=15066597 Then
            MouseWheel("down",10)
            MouseClick("left",297,490)
        EndIf
    WEnd
WEnd

Func Terminate()
  Exit 0
EndFunc
You may be right. For openers I stopped looking after line 4.

Something like While 0 = 0 will usually start my head spinning. Last time I looked it up in an advanced mathematics book 0 was always equal to 0.

George

Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.

Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.***

The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.

Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else.

"Old age and treachery will always overcome youth and skill!"

Link to comment
Share on other sites

There are 3 remarks :

- your $y var is declared twice

- the while $y<531 test is not useful as the $y is randomly between 310 and 530 ! Replace it by a while 1 loop for clarity

- you have several sleep(...) instructions. After these there's now warranty that the active window has'nt changed. You have to check it in your code

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...