Jump to content
Sign in to follow this  
computergroove

For loop in another for loop not working

Recommended Posts

computergroove

Global $SWCount = 0
Global $Number = 5

While 1
        Sleep(1000)
    $SWCount += 1
    If $SWCount >= 120 Then; 2 minutes
    Local $SWX1 = 130
    Local $SWX2 = 180
    Local $SWX3 = 130
    Local $SWX4 = 180
    $SWX1Temp = $SWX1
    For $i = 1 To $Number
        For $j = 10 To $Number
            MouseClick("Left", $SWX1Temp, 255,10)
            $SWX1Temp += 5
        Next
        $SWX1 += 320
        $SWX2 += 320
        $SWX3 += 320
        $SWX4 += 320
    Next
        $SWCount = 0
WEnd

The above code counts to 120 in the tooltip but wont mouse click anything and the tooltip resets to 0 and starts counting to 120 again. Is my syntax wrong?

Edited by computergroove

Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
jdelaney

What are you trying to do?

If $j = 10, and $number = 5, you will NEVER perform a mouseclick...For j=10 To 5 means you never enter the loop, you skip right on by it.

Also, you are missing an EndIf

Ah, so you are only wanting to do something once ever 2 minutes, right?

While 1
    $iTimer = TimerInit()
    ; wait for 2 minutes to pass
    While TimerDiff($iTimer)<120000
        Sleep(10)
    WEnd

    ; now add your code
    
WEnd
Edited by jdelaney

IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites
JohnOne

Global $SWCount = 0
Global $Number = 5

While 1
    Sleep(1000)
    $SWCount += 1
    If $SWCount >= 120 Then; 2 minutes
        Local $SWX1 = 130
        Local $SWX2 = 180
        Local $SWX3 = 130
        Local $SWX4 = 180
        $SWX1Temp = $SWX1
        For $i = 1 To $Number
            For $j = 10 To $Number Step -1 ;<<<<<<<<<<<<<<<<<<<
                MouseClick("Left", $SWX1Temp, 255, 10)
                $SWX1Temp += 5
            Next
            $SWX1 += 320
            $SWX2 += 320
            $SWX3 += 320
            $SWX4 += 320
        Next
        $SWCount = 0
    EndIf
WEnd


AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

Share this post


Link to post
Share on other sites
computergroove

Lol I see the problem. Thanks


Get Scite to add a popup when you use a 3rd party UDF -> http://www.autoitscript.com/autoit3/scite/docs/SciTE4AutoIt3/user-calltip-manager.html

Share this post


Link to post
Share on other sites
caramen
Also, you are missing an EndIf

"End if" necessary ? After "then" parameter in the same line ? (i am not sure :/ )

Share this post


Link to post
Share on other sites
JLogan3o13

caramen, jdelaney is assuming (as I would) that the OP's entire For loop is supposed to be inside the If statement. In this case, he would need and EndIf.


√-1 2^3 ∑ π, and it was delicious!

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  

×