don't blink
don't blink

Reputation: 101

AHK - Sleep inside a function doesn't work (2)

I have read previous similar article and tried as there adviced. But it doesn't work for me. Or I missing something? I tried many syntax variations.

keydelay := 1000

^z::
    PlayQueue([1,2,3,"q","e"])
return

PlayQueue(queue)
{
    global keydelay
    for i, k in queue
        Send, %k%
        Sleep %keydelay%
}

Its just fires instantly without delays :/

Upvotes: 0

Views: 380

Answers (1)

0x464e
0x464e

Reputation: 6489

You can only omit { } if you have a single line statement.
Your for loop's body has two lines, so you'll need braces.

PlayQueue(queue)
{
    global keydelay
    for i, k in queue
    {
        Send, %k%
        Sleep, %keydelay%
    } 
}

Upvotes: 1

Related Questions