Sign in to follow this  
Followers 0
vickerps

Exit out of a loop using key press

9 posts in this topic

I'm sure this is easy but my brain isn't working.

I want a user to exit out of a loop if they press a certain key

Share this post


Link to post
Share on other sites



I'm sure this is easy but my brain isn't working.

I want a user to exit out of a loop if they press a certain key

Lookup HotKeySet in the help file. Remember to look at the example.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

Lookup HotKeySet in the help file. Remember to look at the example.

I do know about hotkeys but doesn't do what i want. i only want to exit out of a loop not exit

this is the script im doing (maybe make things clearer)

$SynchTimeComputer  = PC99

DO
   SplashTexton ""," Waiting for " $SynchTimeComputer &@CRLF&@CRLF& "press esc to skip"
   $p = ping ($SynchTimeComputer) 
UNTIL $p > "0"

Share this post


Link to post
Share on other sites

hotkeyset("{esc}","endloop")
$x = 0
$SynchTimeComputer  = PC99

DO
   SplashTexton ""," Waiting for " $SynchTimeComputer &@CRLF&@CRLF& "press esc to skip"
   $p = ping ($SynchTimeComputer)
if $x = 1 then exitloop
UNTIL $p > "0"

func endloop()
$x = 1
endfunc


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

#include <Misc.au3>

$dll = DllOpen("user32.dll")

$SynchTimeComputer  = PC99

DO
   SplashTexton ""," Waiting for " $SynchTimeComputer &@CRLF&@CRLF& "press esc to skip"
   $p = ping ($SynchTimeComputer) 
UNTIL $p > "0" Or _IsPressed("1B", $dll)
MsgBox(0, "Message", "Loop exited")

Not tested



Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

thats just too much.

simplicity is purity. stick with my example lol


Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Share this post


Link to post
Share on other sites

thats just too much.

simplicity is purity. stick with my example lol

What he said but check your script for typo's.


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I like men

I hope that means you are a female !!!


Get Beta versions Here Get latest SciTE editor Here AutoIt 1-2-3 by Valuater - A great starting point.

Time you enjoyed wasting is not wasted time ......T.S. Elliot
Suspense is worse than disappointment................Robert Burns
God help the man who won't help himself, because no-one else will...........My Grandmother

Share this post


Link to post
Share on other sites

I will try to be the 1st with some working code in this thread.

HotKeySet('a', 'trigger')
$a = 1
$b = 0

While $a = 1
    Sleep(100)
    If stop() Then $a = 0
WEnd

Func trigger()
    $b = 1
EndFunc

Func stop()
    If $b = 1 Then Return 1
EndFunc

The while loop will collapse when $b = 1 The trigger function through HotKetSet() will do this.

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