Jump to content

Wait For Keypress


 Share

Recommended Posts

Ok, I'm making a script and I want the script to simply pause until I press anykey.

The following sentence may not make any sense.

It's also a loop, so I can't just make it a variable. (I can't just say "do" until variable = 1, when you press space bar or something it ads 1 to the variable.)

Basically is there a WaitButtonPress like there is a WinWaitActive.

thanks.

Link to comment
Share on other sites

Hotkeyset is what you are looking for

" I haven't failed. I've just found 10,000 ways that won't work." Thomas Edison "You cannot help men permanently by doing for them what they could and should do for themselves." Abraham Lincoln

Link to comment
Share on other sites

You mean something like this?

#include <Misc.au3>

While 1
    $key=_IsAnyKeyPressed()
    If $key then MsgBox(0,"","You pressed a key!")
WEnd
Func _IsAnyKeyPressed()
    $number = StringSplit("01|02|04|05|06" & _
    "|08|09|0C|0D|10|11|12|13|14|1B|20|21|22" & _
    "|23|24|25|26|27|28|29|2A|2B|2C|2D|2E|30" & _
    "|31|32|33|34|35|36|37|38|39|41|42|43|44" & _
    "|45|46|47|48|49|4A|4B|4C|4D|4E|4F|50|51" & _
    "|52|53|54|55|56|57|58|59|5A|5B|5C|60|61" & _
    "|62|63|64|65|66|67|68|69|6A|6B|6C|6D|6E" & _
    "|6F|70|71|72|73|74|75|76|77|78|79|7A|7B" & _
    "|90|91|A0|A1|A2|A3|A4|A5", "|")
    For $i in $number
        If _IsPressed(String($i)) Then 
            Return 1
        EndIf
    Next
    Return 0
EndFunc
Edited by Paulie
Link to comment
Share on other sites

That's great thanks. I tried both but I think the simple hotkeyset method is working pretty good. I don't really need "Anykey" I meant it can be anykey. I'm just using space bar.

Thanks for your help.

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...