Sign in to follow this  
Followers 0
Jmjl

Loop Help!

10 posts in this topic

I'm trying to make a program that when I click it waits 1 minute and 40 seconds, and then clicks two (2) things and then repeats that over and over. How can I have this loop work?

Share this post


Link to post
Share on other sites



Have a look at:

  • While and WEnd
  • Sleep()
  • HotKeySet() (to provide a nice way to exit, see also FAQ #12)
  • ControlClick()
  • MouseClick()
That should get you started.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

I don't understand how to ake it loop though.

Share this post


Link to post
Share on other sites

I don't understand how to ake it loop though.

<{POST_SNAPBACK}>

There are several examples in the helpfile...

Since I'm feeling a little bit on the nice side, how about I give you some links to the online documentation. I don't suppose you tried a search for the word "loop" in the helpfile? Kinda handy how a lot of this same stuff pops up :ph34r:


[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

While 1

;Commands you want loops

WEnd

Share this post


Link to post
Share on other sites

Another way of looking at this is to use an AdLib function with the timer set for 100 seconds. Put a sleep for several seconds inside a loop. Take a look in the documentation index for AbLib.


David Nuttall
Nuttall Computer Consulting

An Aquarius born during the Age of Aquarius

AutoIt allows me to re-invent the wheel so much faster.

I'm off to write a wizard, a wonderful wizard of odd...

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

Another way of looking at this is to use an AdLib function with the timer set for 100 seconds.  Put a sleep for several seconds inside a loop.  Take a look in the documentation index for AbLib.

<{POST_SNAPBACK}>

A question:

When you have an AdLib func' running...

And the function it runs contains a sleep command that pauses longer than the interval AdLib repeats the function...

What happens?

Edited by SlimShady

Share this post


Link to post
Share on other sites

A question:

When you have an AdLib func' running...

And the function it runs contains a sleep command that pauses longer than the interval AdLib repeats the function...

What happens?

<{POST_SNAPBACK}>

The adlib function will be called during the sleep...

just try to demo it:

$A = 1
AdlibEnable("test")
sleep(10000)
Exit

Func Test()
   SplashTextOn("test",$a)
   $a=$a+1
EndFunc

:ph34r:


Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

A question:

When you have an AdLib func' running...

And the function it runs contains a sleep command that pauses longer than the interval AdLib repeats the function...

What happens?

<{POST_SNAPBACK}>

I created a test script to find out.

It would seem that the AdLib function is allowed to complete itself without interruption, but that it does not allow the code where it left to run the adlib anymore. In effect, you will create an endless loop of the AdLib function. I can't think of why you would want this effect, but I suppose someone might find an interesting way to use it.

The code:

MsgBox(64, "Text Script", "To exit the test, please press alt-q")
HotKeySet("!q", "quit")

AdLibEnable("function", 4000)
Global $executed_main = 0
While 1
  $executed_main = 1
  ToolTip("main loop text", 0, 0)
  Sleep(1000)
WEnd

Func Quit()
  Exit
EndFunc

Func function()
  If $executed_main = 1 Then
    ToolTip("Running AdLib from main loop code", 0, 0)
    Sleep(1000)
  EndIf
  $executed_main = 0
  For $i = 1 To 6
    ToolTip("AdLib tooltip number " & $i, 0, 0)
    Sleep(1000)
  Next
EndFunc

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

Share this post


Link to post
Share on other sites

The adlib function will be called during the sleep...

just try to demo it:

...

<{POST_SNAPBACK}>

I think his question was regarding the AdLib itself. See my example above for what I think he was refering to.

[font="Optima"]"Standing in the rain, twisted and insane, we are holding onto nothing.Feeling every breath, holding no regrets, we're still looking out for something."[/font]Note: my projects are off-line until I can spend more time to make them compatable with syntax changes.

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
Sign in to follow this  
Followers 0