Jump to content

Help with creating a loop


BALA
 Share

Recommended Posts

Func Play()
    For $n = 1 to $click
        MouseClick("left", $x, $y, 1)
    Next
EndFunc

When $n = $click I want the For-Next loop to start all over again. How can I do that?

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

Place this above your function

While 1

Play()

Sleep(10)

Wend

8)

Do I put my function within that While-WEnd?

[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

  • Developers

Do I put my function within that While-WEnd?

What do you think ?

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

Well I wasn't sure if that was a mistake or something. :P

In addition, how could I have the loop stop when I press a key for example.

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

Well I wasn't sure if that was a mistake or something. :P

try it - it is pretty safe code - it is not like it said format.... :-)
While 1
    Play()
    Sleep(10)
WEnd

Func Play()
    For $n = 1 To $click
        MouseClick("left", $x, $y, 1)
    Next
EndFunc   ;==>Play

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

Oh, wait I made a mistake, the function only goes when the F3 key is pressed, so the code is actually:

HotKeySet("{F3}", "Play")

Func Play()
    For $n = 1 to $click
        MouseClick("left", $x, $y, 1)
    Next
EndFunc

So how could I make the For-Next start over when $n = $click? Same way?

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

When I pressed the F3 key I want the For-Next to continuously loop by itself until another key is pressed.

Edited by BALA
[font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com
Link to comment
Share on other sites

When I pressed the F3 key I want the For-Next to continuously loop by itself until another key is pressed.

; Press Esc to terminate script, Pause/Break to "pause"

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySet("{ESC}", "Terminate")
HotKeySet("+!d", "ShowMessage")  ;Shift-Alt-d

;;;; Body of program would go here ;;;;
While 1
    For $n = 1 To $click
        MouseClick("left", $x, $y, 1)
    Next
    Sleep(100)
WEnd
;;;;;;;;

Func TogglePause()
    $Paused = Not $Paused
    While $Paused
        Sleep(100)
        ToolTip('Script is "Paused"', 0, 0)
    WEnd
    ToolTip("")
EndFunc   ;==>TogglePause

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func ShowMessage()
    MsgBox(4096, "", "This is a message.")
EndFunc   ;==>ShowMessage

[size="1"][font="Arial"].[u].[/u][/font][/size]

Link to comment
Share on other sites

:P Ya, could someone explain what the example does....

here is a simpler version that does what you asked for... but you have to add your code for $click, $x and $y

HotKeySet("{ESC}", "Terminate")
HotKeySet("{F3}", "Play")
Global $trigger = 0

While 1
    If $trigger = 1 Then
        For $n = 1 To $click
            MouseClick("left", $x, $y, 1)
        Next
    EndIf
    Sleep(100)
WEnd

Func Terminate()
    Exit 0
EndFunc   ;==>Terminate

Func Play()
    $trigger = 1
EndFunc   ;==>Play
Which line do you not understand? Edited by herewasplato

[size="1"][font="Arial"].[u].[/u][/font][/size]

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