Sign in to follow this  
Followers 0
venezia

Do....Until "I press Escape"

7 posts in this topic

Hi all,

Is there a function to stop a loop until I press a key ?

The script looks like that:

Do

.................

................

....................

......................

Until "Escape is pressed"

Regards :whistle:

Share this post


Link to post
Share on other sites



How about

#include <IsPressed.au3>
While 1
  Sleep(100)  
If _IsPressed('1B') = 1 Then
    
MsgBox(0, "Mouse x,y:","ESC has been Pressed")
ExitLoop
EndIf
WEnd


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

How about

#include <IsPressed.au3>
While 1
  Sleep(100)  
If _IsPressed('1B') = 1 Then
    
MsgBox(0, "Mouse x,y:","ESC has been Pressed")
ExitLoop
EndIf
WEnd

<{POST_SNAPBACK}>

Auto it tells me that there's a mistake with the following line:

If _IsPressed('1B') = 1 Then

What is the reason ?

Share this post


Link to post
Share on other sites

Auto it tells me that there's a mistake with the following line:

If _IsPressed('1B') = 1 Then

What is the reason ?

<{POST_SNAPBACK}>

Use HotKeySet ... that's supported without an UDF... or look up the UDF _IsPressed() and include the code.... (will be part of the Next Beta installer)

Visit the SciTE4AutoIt3 Download page for the latest versions  - Beta files                                How to post scriptsource        Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Use HotKeySet ... that's supported without an UDF... or look up the UDF _IsPressed() and include the code.... (will be part of the Next Beta installer)

<{POST_SNAPBACK}>

I tried HotKeySet("ESC", "ExitLoop") without success

But this one works perfectly even if it's quite brutal :whistle:

While 1

......................................
......................................
HotKeySet("{ESC}", "Terminate")

WEnd

Func Terminate()
Exit 0
EndFunc

Thnak you very much all :dance:

Edited by venezia

Share this post


Link to post
Share on other sites

You don't need to set the hotkey each time the loop runs...

Share this post


Link to post
Share on other sites

More specifically, this will also work for you:

hotkeySet("{ESC}", "terminate")

while 1
    ···
    ···
; don't forget a short delay!
    sleep(100)
wEnd

func terminate()
    exit
endFunc

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