Sign in to follow this  
Followers 0
AniperLeo

_IsPressed and Qoutes, Colins, Braces

4 posts in this topic

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



I don't know where are you from. I'm from germany and on german keyboard you have not a seperat key for every sign you named. I think it's in other languages too. :P

So is "/" and "{" on key "7". "~" and "*" are one key "+". And so can _IsPressed() detect all keys. :)


Best Regards BugFix  

Share this post


Link to post
Share on other sites

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

While 1
    Sleep(250)
    $typed = _IsPressedMod($dll)
    If $typed Then ExitLoop
WEnd
DllClose($dll)

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)
    Next
    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

#4 ·  Posted (edited)

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  
Followers 0