Jump to content

Recommended Posts

Global $iLoop = True
HotKeySet("{ESC}", "_ExitLoop")
Func Button1()
    $iLoop = True
    While $iLoop
      Sleep(2500)
      MouseClick ("left")
    WEnd
    $iLoop = False
EndFunc
Func _ExitLoop()
    $iLoop = False
EndFunc

I want this to left click in a loop until I hit the key esc but it doesnt seem to be working. Although it does left click, i just cant get it to stop! 

Edited by earthwarder
Link to post
Share on other sites
  • Developers

This script never starts Button1(), so please shown a script that actually demonstrates the problem.

Jos

Edited by Jos

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 post
Share on other sites
  • Developers

I have no idea why you changed the script to what you show in the last post and all I was saying is that your first script was not complete and can never have done a mouseclick as the Button1() func was never called.

This works fine for me:

Global $iLoop = True
HotKeySet("{ESC}", "_ExitLoop")

Func Button1()
    $iLoop = True
    While $iLoop
        ConsoleWrite('@@ Debug(' & @ScriptLineNumber & ') : $iLoop = ' & $iLoop & @CRLF & '>Error code: ' & @error & @CRLF) ;### Debug Console
      Sleep(2500)
;~       MouseClick ("left")
    WEnd
    $iLoop = False
EndFunc

Func _ExitLoop()
    $iLoop = False
EndFunc

Button1()

Jos

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 post
Share on other sites

Oh, yes that totally makes sense. Thank you.

I have taken it a little further with another hotkey for starting it and exiting, but I wanted to try to add a pause. I can play and exit just fine, but the pause I'm trying to implement isn't working. Here's what I got so far.

HotKeySet("{F1}", "PlayScript")
HotKeySet("{ESC}", "ExitScript")
HotKeySet("{F2}", "PauseScript")
Global $iLoop = True
Global $Pause

While 1
   WEnd

Func Playscript()
    $iLoop = True
    While $iLoop
      Sleep(2500)
      MouseClick("left")
    WEnd
    $iLoop = False
EndFunc

Func ExitScript()
    $iLoop = False
    Exit
EndFunc

Func TogglePause()
   $Paused = Not $Paused
   While $Paused
      sleep(100)
      ToolTip("Script is Paused!,0,0)
   WEnd
   ToolTip()
EndFunc

 

Edited by earthwarder
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...