PDA

View Full Version : Last-Typed-Char: a very "basic" question



ReneMiner
22-05-2013, 11:01
Is there a way to get the last typed character (chr$) from its %VK_Equate on the users localized keyboard - so if I type some "ü" or whatever "+#-.,ß?" the charcode for that letter or the asc itself can be read out from somewhere? If I type some "Z" - it's located between "T" and "U" while my "Y" is the key left from "X"- on other keyboards it's vice-versa...

Now is there some function to get the last typed char from %VK_Equate (except console)?

Petr Schreiber
22-05-2013, 11:16
I am quite sure there is no last key remembered anywhere by default, but there is a way to convert VK_CODE to ASCII value:


%MAPVK_VK_TO_VSC = 0
%MAPVK_VSC_TO_VK = 1
%MAPVK_VK_TO_CHAR = 2
%MAPVK_VSC_TO_VK_EX = 3
Declare Function MapVirtualKey Lib "USER32.DLL" Alias "MapVirtualKeyA" ( ByVal uCode As DWord, ByVal uMapType As DWord ) As DWord

String sChars
Long i
For i = %VK_1 To %VK_9
sChars += Chr$(MapVirtualKey(i, %MAPVK_VK_TO_CHAR))
Next

MsgBox 0, sChars


Petr