.net - I always get a '255' value as keycode of these characters. How to retrieve the right keycode? -
i don't understand next issue.
i'm using function vkkeyscanex retrieve virtual-keycode of character, low-order byte of value returns function retrieve keycode.
all works expected these characters same keycode 255
áéíóú ÁÉÍÓÚ àèìòù ÀÈÌÒÙ äëïÖÜ ÄËÏÖÜ
both low-order byte , high-order byte returns me vkkeyscanex
function 255
chars.
i don't know 255
, 'cause print character this:
msgbox(convert.tochar(255))
i don't know if error or proper value, anyways i've tried specify keyboard layout (which 10
) using getkeyboardlayout function still same 255
value.
someone explain me if value right , means 255
keycode?, if not, how transform chars in right keycode?
this code i'm testing:
imports system.runtime.interopservices public class form1 private sub test() handles mybase.shown dim sb new system.text.stringbuilder dim characters char() = "abcdefghijklmnopqrstuvwxyz ñÑçÇ áéíóú ÁÉÍÓÚ àèìòù ÀÈÌÒÙ äëïÖÜ ÄËÏÖÜ º\'¡`+´-.,ª!·$%&/()=?¿".tochararray each c char in characters sb.appendformat("character: {0}", cstr(c)) sb.appendline() sb.appendformat("keycode : {0}", cstr(getkeycode(c, getkeyboardlayout(intptr.zero)))) messagebox.show(sb.tostring) sb.clear() next c end sub <dllimport("user32.dll", charset:=charset.unicode)> private shared function vkkeyscanex( byval c char, optional byval keyboardlayout intptr = nothing ) short end function <dllimport("user32.dll", entrypoint:="getkeyboardlayout", charset:=charset.unicode)> private shared function apigetkeyboardlayout( optional byval idthread intptr = nothing ) uinteger end function ''' <summary> ''' translates character corresponding keycode. ''' </summary> public shared function getkeycode(byval c char, optional byval keyboardlayout intptr = nothing) short return bitconverter.getbytes(vkkeyscanex(c)).first end function ''' <summary> ''' retrieves active input locale identifier (formerly called keyboard layout). ''' </summary> public shared function getkeyboardlayout(optional byval idthread intptr = nothing) short return bitconverter.getbytes(apigetkeyboardlayout(idthread)).first end function end class
msdn says:
if function finds no key translates passed character code, both low-order , high-order bytes contain –1.
which you're getting, interpreted unsigned byte. guess keyboard (or layout you're specifying) not have keys characters.
Comments
Post a Comment