Sign in to follow this  
Followers 0
BALA

Help with creating a loop

16 posts in this topic

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

Share this post


Link to post
Share on other sites



Place this above your function

While 1

Play()

Sleep(10)

Wend

8)


NEWHeader1.png

Share this post


Link to post
Share on other sites

Place this above your function...


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

Share this post


Link to post
Share on other sites

#6 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Press the F3 key again???

I do not understand your question...


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

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

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

Share this post


Link to post
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]

Share this post


Link to post
Share on other sites

#12 ·  Posted (edited)

take a look at "HotKeySet()" in help

at the bottom is a GREAT example

8)

NVM - plato was good enough to do it for you

Edited by Valuater

NEWHeader1.png

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

: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]

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