Jump to content

Multiple Functions within One Loop?

Recommended Posts

Hi, i was wondering if, and if yes, How i would go about creating a loop with multiple functions?

While 1

MouseClick ("left")

AutoitSetOption ("MouseClickDelay" , 4500)


But add something like this into it while not interferring with the Mouseclick Loop

Send ("F1")

Opt("SendKeyDelay" , 36000000)

So that the F1 key will be pressed at 45 minute intervals, while the Left Mouse clicking will continue to function without any interferrence.

At first ive tried to combine the Send command into the While 1 Wend brackets, but that made the script not function anymore, i believe it is because the script pauses for 45 minutes while waiting to press the F1 key beofre continuing with the rest of the script.

What i am aiming to do is create a script with multiple functions inside loops, so that the Mouse will continue to click at 4500 millisecond intervals, and the F1 keystroke will be sent at 45 minute intervals and loop these functions forever, using the While 1 loop brackets.

Thank you for any and all help.

I just want to apologize for my obvious and blatantly covered questions, the Autoit Help file doesnt really tell me much, it just gives me an example and the variables and a few other pieces of knowledge that dont explain to me the proper function and scripting sequences for the direction i am aiming to get.

I dont mean to sound like a whiner, but its true, Im just a complete novice at AutoIt, and the Help file explains things to me as if i were a completely informed intermediate user. Im sure i skipped over some parts in the beginning, novices usually do that(true story), but if anyone knows a website ora section in the help file that explains scripting and proper script sequencing in a user friendly step by step guide, that would be great.

Thanks again. Hope to hear from you.

Link to post
Share on other sites

I like Nuffilein's approach -- much cleaner than the approach that I was going to take with TimerInit() and TimerDiff().

Here's a small improvement on Nuffilein's idea (hopefully the logic is a bit clearer):

; Declare your variables!
Local $I

; Loop indefinitely
While 1


    ; Loop 600 times (45m รท 4.5s = 600)
    For $I = 1 To 600
        ; Pause for 4.5s
        Sleep(4.5 * 1000)

Link to post
Share on other sites

Thank you for your quick responses, Nuffilein and LxP.

Just a quick follow up question.

Do all keystrokes have to be contained into quotes like {} in order for them to be recognized.

And also, does Nuffileins version loop indefinetly, or does LxP's only loop in definetly.


Local $I

What is this value?

Link to post
Share on other sites

Certain keystrokes need to be surrounded by braces to be recognised. They are listed in the help file under Send(). All other keys can be written as normal.

Both scripts loop indefinitely, so that's not a problem.

Local $I simply says 'I intend to use a variable called $I somewhere'. It's not necessary to do (Nuffilein does not do it for his/her $a) but it's very good programming practice to declare your variables.

Edited by LxP
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
  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...