Sign in to follow this  
Followers 0
Doug Porter

While inside while

11 posts in this topic

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

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

[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

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

Share this post


Link to post
Share on other sites

what does compile do, or why would i use it?

thanks for the help.

Share this post


Link to post
Share on other sites

what does compile do, or why would i use it?

thanks for the help.

http://en.wikipedia.org/wiki/Compiler

[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

the reason i put the {esc} function in the while is becouse i thought that if it was outside then i would get stuck looping and ot be able to stop the script. i guess that it doesn't matter?

it did seem to fix the problem.

Thanks to all.

Share this post


Link to post
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!"

Share this post


Link to post
Share on other sites

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.

thats the point, the body will loop indefinitely.

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

you can just put while 1 it stands for while 1 = 1 just short, hell if you want put while 0 or while 0 = 0 and 1 = 1 and 2 =2 :whistle: all the same, im just getting at that you can just put while and a number ;)

Edited by thatsgreat2345

Share this post


Link to post
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

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