AutoHotkey Homepage AutoHotkey Community
Let's help each other out
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

looking for an on/off toggle

 
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help
View previous topic :: View next topic  
Author Message
aDot
Guest





PostPosted: Mon Jun 28, 2004 3:21 pm    Post subject: looking for an on/off toggle Reply with quote

Hi,

I have little programming experience and stumbled over the following problem that I cannot resolve myself:

I would like to write a script that can be started with one of the function keys, that is looping a certain command with a specific sleep time. So far no problem, but here is my challenge:

The loop should stop if the user presses another function key, else it should continue to loop endless.

Is that possible? If yes, could you give me a hint on that?


Thanks from a very beginner.

aDot
Back to top
BoBo
Guest





PostPosted: Mon Jun 28, 2004 3:30 pm    Post subject: Reply with quote

E.g the F12 key:

Code:
~F12::Exit
Back to top
BoBo
Guest





PostPosted: Mon Jun 28, 2004 3:33 pm    Post subject: Reply with quote

Embarassed shouldn't abort the script at all, correct ?!

~F12::break
Back to top
BoBo
Guest





PostPosted: Mon Jun 28, 2004 3:41 pm    Post subject: Reply with quote

Well, seems to be complete nonsense what I've written above Confused
Sorry. Embarassed
Back to top
aDot
Guest





PostPosted: Mon Jun 28, 2004 3:41 pm    Post subject: Thank you Reply with quote

Thanks a lot for the quick help - will try it tonight.
Back to top
beardboy



Joined: 02 Mar 2004
Posts: 444
Location: SLC, Utah

PostPosted: Mon Jun 28, 2004 3:44 pm    Post subject: Reply with quote

To not kill the script, just the running loop you could do something like this:

Code:
F1::
loopkill = 0 ; Reset variable to kill loop
Loop
{
  ; Have normal commands for loop.
  Sleep, 1000
  if loopkill = 1
    break
}
return

F2::
loopkill = 1
return

thanks,
beardboy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
silentblood



Joined: 19 Jun 2004
Posts: 36

PostPosted: Fri Jul 02, 2004 7:59 pm    Post subject: Reply with quote

If I am reading this right will it only stop once it reaches the if command in the script so it would only pause once it got to that if command?
Back to top
View user's profile Send private message
Chris
Site Admin


Joined: 02 Mar 2004
Posts: 10467

PostPosted: Fri Jul 02, 2004 8:20 pm    Post subject: Reply with quote

That's right, but you can repeat the same IF statement in multiple places throughout the body of the loop -- notably after any operation that takes a long time -- if you need the stop key to be more immediate.
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    AutoHotkey Community Forum Index -> Ask for Help All times are GMT
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum


Powered by phpBB © 2001, 2005 phpBB Group