Jump to content
Sign in to follow this  

_IsPressed and Qoutes, Colins, Braces

Recommended Posts

Can _IsPressed detect the ~ ` [ { ] } | : ; " ' , < . > keys?

I did not see this question answered when I searched the forum and I'm a little perplexed as to why no one has asked. I'm trying to write a program that teaches users the shortcut functions of a program and what they do, but I can't figure out how to detect those key-presses listed above, and it is not in the manual. I am running the latest beta of autoit that I know of.

Share this post

Link to post
Share on other sites

$dll = DllOpen("user32.dll")
While _IsPressedMod($dll) ; clear buffer

While 1
    $typed = _IsPressedMod($dll)
    If $typed Then ExitLoop

ConsoleWrite($typed & @LF)

; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/WindowsUserInterface/UserInput/VirtualKeyCodes.asp
Func _IsPressedMod($dll = "user32.dll")
    Local $aR, $bRv, $hexKey, $i
    For $i = 1 To 256
        $hexKey = '0x' & Hex($i, 2)
        $aR = DllCall($dll, "int", "GetAsyncKeyState", "int", $hexKey)
        If $aR[0] <> 0 Then Return Hex($i,2)
    Return 0
EndFunc   ;==>_IsPressedMod

SciTE for AutoItDirections for Submitting Standard UDFs


Don't argue with an idiot; people watching may not be able to tell the difference.


Share this post

Link to post
Share on other sites

Thank you VERY much gafrost, the functions work perfectly and the link to the keycodes was insanely useful. Many props!

Edited by AniperLeo

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  

  • Create New...