Jump to content

Exit a For loop with keyboard input?


Nagasa
 Share

Recommended Posts

I'm sure this is something very simple but i cant seem to figure it out.

I've tried _IsPressed, @HotkeyPressed. The solution i'm using right now requires me to hold the key until the end of the loop, but i would like a way so that the instant i press the button the loop ends and the code continues.

And Thank you in advance for anyone who replies.

Func example()
    -code-
    _isPressed("1B") Then ExitLoop
EndFunc

 

~ Just Your Friendly Neighborhood Nerd With Too Much Free Time.~

Link to comment
Share on other sites

37 minutes ago, Subz said:

Try something like:

HotKeySet("{ESC}", "_ExitLoop")
Global $bLoop = True
While $bLoop
    Sleep(100)
WEnd
MsgBox(4096, "Exit Loop", "Complete")
Func _ExitLoop()
    $bLoop = False
EndFunc

 

I'm running my code within a for loop and for whatever reason the example you've provided doesn't work, even tho in theory it should.

~ Just Your Friendly Neighborhood Nerd With Too Much Free Time.~

Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...