Jump to content
Sign in to follow this  
Guest OnlyFox

Conditional Break from Inf Loop

Recommended Posts

Guest OnlyFox

Im trying to write a simple mouse double click macro that loops infinitely until told to stop by user input.

Its been years since I have done any type of programing and that was with plain straight C (oh, and I wasnt very good then)

Basicaly what i have so far:

If <condition> Then

MouseClick("left",x,y,2)

MouseClick("left",x,y,2)

MouseClick("left",x,y,2)

Else Exit

EndIf

now the question is how do i make the condition such that it looks for a specific key stroke to end the macro... and is the "Else Exit" correct syntax to end the macro?

Any help would be appreciated

Share this post


Link to post
Share on other sites
Guest OnlyFox

I may have found my own answer, but would like someone to eyeball it to confirm before I try to run it.. Nothing like ending up in a loop that causes you to have to hard stop your system.

Global $Paused

HotKeySet("{PAUSE)", "TogglePause")

HotKeySEt("{ESC}", "Terminate")

;;;;;;;;;

Do

MouseClick("left",x,y,2)

MouseClick("left",x,y,2)

MouseClick("left",x,y,2)

Until $Paused = 1

;;;;;;;;;;

While 1

Sleep (1000)

WEnd

;;;;;;;;;;;

Func TogglePaus{}

$Paused = NOT $Paused

While $Paaused

Sleep(1000)

WEnd

EndFunc

;;;;;;;;;;;

Func Terminate{}

Exit 0

EndFunc

Share this post


Link to post
Share on other sites

looks a bit messed up, I would put in more qualifiers if using it, and also I assume you are using more than one location in the repeated mouseclicks. Also you misspelled Paaused so you will get an error with the variable

also you have a lot of code issues:

Global $Paused
HotKeySet("{PAUSE}", "TogglePause")
HotKeySEt("{ESC}", "Terminate")
;;;;;;;;;
Do
MouseClick("left",10,10,2); if same location, just mouseclick 6 times
MouseClick("left",10,10,2)
MouseClick("left",10,10,2)
; sugestion
; if winactive("My program","") then MouseClick("left",10,10,6)
sleep(100); I would think you would like some pause.
Until $Paused = 1
;;;;;;;;;;
; this section does nothing as you will never have $Paused=1 with your curent code
While 1
Sleep (1000)
WEnd
;;;;;;;;;;;
Func TogglePause()
$Paused = NOT $Paused
While $Paused
Sleep(1000)
WEnd
EndFunc
;;;;;;;;;;;
Func Terminate()
Exit 0
EndFunc
Edited by scriptkitty

AutoIt3, the MACGYVER Pocket Knife for computers.

Share this post


Link to post
Share on other sites
Guest OnlyFox

Thanks for the responce. It will double click 3 diff spots thats why i didnt bother with the x,y coords since thats easy to figure out. I will most likely just rip out the the "paused" portions since i dont really need it. From what I can tell you are in aggrement the the "exit" portions will work and that is what is important.

I pulled that code (aside from my mouse clicks) from the AutoItV3 help file under the Hotkeys issue. :lmao: But I proly misinterpreted the code that was placed there.

Ill try running this now and let you know how it works.

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  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...