Jump to content

Sleep in a while loop


Recommended Posts

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();

 

Link to comment
Share on other sites

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?

SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   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.

Link to comment
Share on other sites

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();

 

Link to comment
Share on other sites

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
SciTE4AutoIt = 3.7.3.0   AutoIt = 3.3.14.2   AutoItX64 = 0   OS = Win_10   Build = 19044   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.

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