Sign in to follow this  
Followers 0
PCode

Check for any key

4 posts in this topic

Is there a way to check to see if any key on the keyboard is being pressed down? I want to make an algorithm that loops sleep until all of the keyboard keys are released.

Share this post


Link to post
Share on other sites



_IsPressed()

Share this post


Link to post
Share on other sites

_IsPressed()

But I couldn't figure out how to make sure all the keys are released.

Are you suggesting that I have to use _IsPressed() for every key?

Share this post


Link to post
Share on other sites

But I couldn't figure out how to make sure all the keys are released.

Are you suggesting that I have to use _IsPressed() for every key?

Yes, it's not that hard.

#include <Misc.au3>

While 1
    If _IsAnyKeyPressed() then MsgBox(0,"","You did something!")
    Sleep(100)
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

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