Nested for loop slowing down for unknown reason (autoit)

112 Views Asked by At

My code:

Func myFunc()

    $lag = 1300
    while (1)
        MouseMove(870, 189)
        sleep(10)
        LC(870, 189)
        sleep(1200 + $lag)
        LC(1010,333)
        sleep(100)
        RC(826,115)
        sleep(50)
        LC(870,212)
        sleep(50)
        send("{ESC}")
        sleep(150)
        $x = 0
        $y = 0

        For $i = 0 To 27 Step 1
            sleep(11)
            MouseClick("left", 1158 + $x ,260 + $y)
            $x+=42
            if ($x = 168) Then
                $x = 0
                $y+=36
            EndIf
        Next

    WEnd

EndFunc

The only delay within the for loop is the sleep(11) but it takes about .5 seconds (500ms) for each iteration rather than 11ms + whatever small delay. Also, completely removing the sleep(11) part of the loop still results in an approximately 500ms delay.

Incase anyone was wondering, it's a video game macro; the first part of the while loop opens an interface and sets something up while the second part (the for loop) is suppose to click through the inventory very quickly.

1

There are 1 best solutions below

0
On

The mouse cursor takes time to move. Set the speed parameter to 0 to make it move instantly

MouseClick("left", 1158 + $x ,260 + $y,1,0)