Jump to content

While.... Wend And Loops


Recommended Posts

Ok, I'm having trouble with this concept..

It's a basic idea, but I think has too indepth of a way to make it work.

Say I want to insert the letter A, B, and C.

But I want to insert A every 3 seconds, B every 5 seconds, and C every 8 seconds...

How do I create a little snippet that would allow that? Because you can't use more than 1 While....WEnd command back to back?

I've tried a few different ways, but nothing works for me.

Please help! It's not a difficult idea and shouldn't require more than 10 lines to do, so please help. :think:

Link to comment
Share on other sites

maybe

$begin1 = TimerInit()
$begin2 = TimerInit()
$begin3 = TimerInit()

While 1
    
    
    
    $dif1 = TimerDiff($begin1)
    If $dif1 >= 3000 Then
        MsgBox(0, "Time Difference 1", $dif1, 1)
    ; Send("A")
        $begin1 = TimerInit()
    EndIf
    
    $dif2 = TimerDiff($begin2)
    If $dif2 >= 5000 Then
        MsgBox(0, "Time Difference 2", $dif2, 1)
    ; Send("B")
        $begin2 = TimerInit()
    EndIf
    
    $dif3 = TimerDiff($begin3)
    If $dif3 >= 8000 Then
        MsgBox(0, "Time Difference 3", $dif3, 1)
    ; Send("C")
        $begin3 = TimerInit()
    EndIf
    
WEnd

just remove the message boxes and the semi-colins

8)

NEWHeader1.png

Link to comment
Share on other sites

Hi,

nice Valuater. Maybe my easy solution works as well :think:

HotKeySet("{esc}", "end")

Dim $i = 0

While 1
    Sleep(1000)
    $i += 1
    Select
        Case $i = 3
            Send("A")
        case $i = 5
            Send("B")
        case $i = 8
            Send("C")
            $i = 0
    EndSelect
WEnd

Func end()
    Exit(0)
EndFunc

So long,

Mega

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Hi,

nice Valuater. Maybe my easy solution works as well :think:

HotKeySet("{esc}", "end")

Dim $i = 0

While 1
    Sleep(1000)
    $i += 1
    Select
        Case $i = 3
            Send("A")
        case $i = 5
            Send("B")
        case $i = 8
            Send("C")
            $i = 0
    EndSelect
WEnd

Func end()
    Exit(0)
EndFunc

So long,

Mega

you need more than one variable to keep the timing correct

8)

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

HI,

after C was sent. --> in the 3rd case statement. yes, it won't be that correct, but it is easy to understand and I didn't know whether he / she needs that exact time. :think:

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

look again... its not going to work at 6 seconds or 10 seconds... etc

6 seconds is the 2nd "A"... and 10 seconds is the 2nd "B"... etc

8)

Okay okay, you won. It was just a quick and dirty soultion. :think:

So long,

Mega

Edited by th.meger

Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Link to comment
Share on other sites

Okay okay, you won. It was just a quick and dirty soultion. :think:

So long,

Mega

you know... now that i think about it

i answered his question... as he asked it... but

I think YOU answered what he/she really wanted ( and he just didn't explain it very good )

lol...oh-well

8)

BTW

i liked your mili-second script... i put it in the autoit wrappers thread

Edited by Valuater

NEWHeader1.png

Link to comment
Share on other sites

Hi,

nice Valuater. Maybe my easy solution works as well :think:

HotKeySet("{esc}", "end")

Dim $i = 0

While 1
    Sleep(1000)
    $i += 1
    Select
        Case $i = 3
            Send("A")
        case $i = 5
            Send("B")
        case $i = 8
            Send("C")
            $i = 0
    EndSelect
WEnd

Func end()
    Exit(0)
EndFunc

So long,

Mega

In stead of using $i = 3 you should use MathCheckDivide or write your own. In that case it will work, and you shouldn't reset I anywhere.
Link to comment
Share on other sites

I felt I was descriptive enough...

All I said was, every 3 seconds A needs to be send, every 6 B needs to be sent and every 8 C needs to be sent.

They have to go off at exact times, and have to loop... Not just do it once.. but send A like infinity times.. lol

Edited by kw_rock
Link to comment
Share on other sites

  • Moderators

I felt I was descriptive enough...

All I said was, every 3 seconds A needs to be send, every 6 B needs to be sent and every 8 C needs to be sent.

They have to go off at exact times, and have to loop... Not just do it once.. but send A like infinity times.. lol

Valuater gave you what you asked for specifically... Did it work?

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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