SmithWesson

Sleep in a while loop

4 posts in this topic

#1 ·  Posted

Hello AutoIt members,

 

I was messing around with the script learning it and came across an issue that I'm unable to solve. This script doesn't apply to anything besides sending the pagedown key twice then waiting for a few seconds and repeating. I was writing this just to get more familiar with it and was using excel as a foundation. Essentially I am just messing around, but looking to have it hit page down twice back to back then waiting it out 4 or 5 seconds, rinse repeat. All it does is continue to send pagedown every 400ms (at least I assume 400ms) but never sits idle the 4000ms.

 

Can you guys give me a sanity check below to see what I'm doing wrong?

 

Global $multiple

Func fastread();
    While 1
        While $multiple2 > 0
            send("{PGDN}");
            sleep(400);
            $multiple2 = $multiple2-1;
        WEnd
        Sleep (4000);
    WEnd
EndFunc

fastread();

 

Share this post


Link to post
Share on other sites



#2 ·  Posted

Hi.

What is $multiple2 defined the first time? And where is $multiple2 resetted to this default to start the inner while wend again? The inner while wend seems to run endlessly because the condition could never proved right.

Regards, Conrad

P.S. It's only one very short line you have to insert. Think about it and when you don't get it I will say it to you. Ok?


SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

Share this post


Link to post
Share on other sites

#3 ·  Posted

Simpel,

 

Ah I wrote that up at work from memory on how I did at from home. Looks I had it almost right except for 1 line of code (which I think is what you're referring to) but it still doesn't work.

 

Global $multiple

$multiple=2

Func fastread();
    While 1
    $multiple2 = $multiple
        While $multiple2 > 0
            send("{PGDN}");
            sleep(400);
            $multiple2 = $multiple2-1;
        WEnd
        Sleep (4000);
    WEnd
EndFunc

fastread();

 

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Hi.

It works for me. The only thing I changed is uncomment Send() and add ConsoleWrite() because then I can see much better if the loop is running correct.

Global $multiple

$multiple=2

Func fastread();
    While 1
    $multiple2 = $multiple
        While $multiple2 > 0
;~             send("{PGDN}");
            ConsoleWrite("PGDN" & @CRLF)
            sleep(400);
            $multiple2 = $multiple2-1;
        WEnd
        Sleep (4000);
    WEnd
EndFunc

fastread();

Some notes beside. You declared $multiple but not $multiple2. Put all of your functions at the end of your code. You can run your loops w/o $multiple.

fastread()

Func fastread()
    Local $multiple2
    While 1
    $multiple2 = 2
        While $multiple2 > 0
;~             send("{PGDN}")
            ConsoleWrite("PGDN" & @CRLF)
            sleep(400)
            $multiple2 = $multiple2 - 1
        WEnd
        Sleep (4000)
    WEnd
EndFunc

Regards, Conrad

Edited by Simpel
misspelling

SciTE = 3.6.2.0/full   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win7Pro SP1   OSArch = X64   Language = 0407/german
H:\...\AutoIt3\SciTE   H:\...\AutoIt3   H:\...\AutoIt3\Include   H: = Network Drive

   88x31.png  Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind.

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