Jump to content

For loop in another for loop not working


Recommended Posts

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

Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Also, you are missing an EndIf

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

My video tutorials : ( In construction )  || My Discord : https://discord.gg/S9AnwHw

How to Ask Help ||  UIAutomation From Junkew || WebDriver From Danp2 || And Water's UDFs in the Quote

Spoiler

 Water's UDFs:
Active Directory (NEW 2018-10-19 - Version 1.4.10.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (2018-10-31 - Version 1.3.4.1) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
PowerPoint (2017-06-06 - Version 0.0.5.0) - Download - General Help & Support
Excel - Example Scripts - Wiki
Word - Wiki
 
Tutorials:

ADO - Wiki

 

Link to comment
Share on other sites

  • Moderators

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.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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