GetAsyncKeyState in diffrent languages
-
Hi I used the GetAsyncKeyState API function Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short My problem is that I have to know if the key that pressed is the English or other languages to print out the key which is pressed thank you in advance to helping me out
-
Hi I used the GetAsyncKeyState API function Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Integer) As Short My problem is that I have to know if the key that pressed is the English or other languages to print out the key which is pressed thank you in advance to helping me out
A key isn't pressed in any language; a key is merely a key, and a combination of keys produces a character. You cannot map key 'a' to character 'a', because it might be that the user is typing 'A'. Alt-A doesn't even count as a character. Hence, you'll have to figure out what the character the keys would map[^] to.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
A key isn't pressed in any language; a key is merely a key, and a combination of keys produces a character. You cannot map key 'a' to character 'a', because it might be that the user is typing 'A'. Alt-A doesn't even count as a character. Hence, you'll have to figure out what the character the keys would map[^] to.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
Your sig is all wrong in this forum; as the OP posted some VB code (you didn't notice?) he should use a translator the other way around... :-D
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
A key isn't pressed in any language; a key is merely a key, and a combination of keys produces a character. You cannot map key 'a' to character 'a', because it might be that the user is typing 'A'. Alt-A doesn't even count as a character. Hence, you'll have to figure out what the character the keys would map[^] to.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
thank you so much, what I want to do is what you mentioned above. what I mean here is to have a character of the key which is pressed,but in different language(the language that is in the layout) I have seen this function before but, I ran into lot's of problem(sorry I don't have lot's of experience)first is that by using GetAsyncKeyState I can't access to the virtualkeycode, the next problem is that I don't know which type of mapping should I use to reach to my goal . Part of my code is written below:
foreach (System.Int32 i in Enum.GetValues(typeof(Keys)))
{
int k=i;
if( (KeyLogger.Methods.GetAsyncKeyState(i)== 1) ||(KeyLogger.Methods.GetAsyncKeyState(i) == Int16.MinValue))
{
keyBuffer += Enum.GetName(typeof(Keys), i) + " ";
} -
Your sig is all wrong in this forum; as the OP posted some VB code (you didn't notice?) he should use a translator the other way around... :-D
Luc Pattyn [My Articles] Nil Volentibus Arduum
-
thank you so much, what I want to do is what you mentioned above. what I mean here is to have a character of the key which is pressed,but in different language(the language that is in the layout) I have seen this function before but, I ran into lot's of problem(sorry I don't have lot's of experience)first is that by using GetAsyncKeyState I can't access to the virtualkeycode, the next problem is that I don't know which type of mapping should I use to reach to my goal . Part of my code is written below:
foreach (System.Int32 i in Enum.GetValues(typeof(Keys)))
{
int k=i;
if( (KeyLogger.Methods.GetAsyncKeyState(i)== 1) ||(KeyLogger.Methods.GetAsyncKeyState(i) == Int16.MinValue))
{
keyBuffer += Enum.GetName(typeof(Keys), i) + " ";
}a.fatemeh wrote:
I have seen this function before but, I ran into lot's of problem(sorry I don't have lot's of experience)
You'll rarely be building the same thing twice, which means that you'll constantly be discovering new things with which you don't have experience. Here's[^] part of your puzzle, enjoy.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
a.fatemeh wrote:
I have seen this function before but, I ran into lot's of problem(sorry I don't have lot's of experience)
You'll rarely be building the same thing twice, which means that you'll constantly be discovering new things with which you don't have experience. Here's[^] part of your puzzle, enjoy.
Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]
-
It's not what I mean. below is kind of my problem : http://msgroups.net/microsoft.public.vc.mfc/mapvirtualkey-in-different-languages/130087[^] thank you so much I'm really sorry if I taking up your time.
-
:) yes,it's kind of my answer ,the code has problem which one of them was mentioned below the code is that MapVirtualKey actually returns a uint, not an int. part of Mycode is as below but it's just show nothing which I couldn't find where the problem is;
//vkey is an arrey of virtualkeycode for example Vkey[1, 35] = 0x5A which is for Z;
const uint MAPVK_VK_TO_VSC_EX = 0x04;
const uint KLF_ACTIVATE = 0x00000001;
textBox2.Text = InputLanguage.CurrentInputLanguage.Culture.EnglishName;
for (int i=0; i<120; i++)
{
if( (KeyLogger.Methods.GetAsyncKeyState(Vkey[1,i])== 1) || (KeyLogger.Methods.GetAsyncKeyState(Vkey[1,i]) == Int16.MinValue))
{
uint temp=KeyLogger.Methods.MapVirtualKeyEx((Convert.ToUInt32(Vkey[1,i])),MAPVK_VK_TO_VSC_EX,KeyLogger.Methods.LoadKeyboardLayout(InputLanguage.CurrentInputLanguage.Culture.KeyboardLayoutId.ToString(),KLF_ACTIVATE));
StringBuilder keyname=new StringBuilder();
int nsize=50;
if (KeyLogger.Methods.GetKeyNameText(Convert.ToInt32(temp),keyname,nsize) !=0)
{
keyBuffer+=keyname.ToString();
}
}
}
if (keyBuffer != string.Empty)
textBox1.Text=keyBuffer;