Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. GetAsyncKeyState in diffrent languages

GetAsyncKeyState in diffrent languages

Scheduled Pinned Locked Moved C#
jsonhelp
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    a fatemeh
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • A a fatemeh

      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

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      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[^]

      L A 2 Replies Last reply
      0
      • L Lost User

        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[^]

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        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

        L 1 Reply Last reply
        0
        • L Lost User

          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 Offline
          A Offline
          a fatemeh
          wrote on last edited by
          #4

          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) + " ";
          }

          L 1 Reply Last reply
          0
          • L Luc Pattyn

            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

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            :laugh:

            Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

            1 Reply Last reply
            0
            • A a fatemeh

              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) + " ";
              }

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              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 1 Reply Last reply
              0
              • L Lost User

                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 Offline
                A Offline
                a fatemeh
                wrote on last edited by
                #7

                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.

                L 1 Reply Last reply
                0
                • A a fatemeh

                  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.

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #8

                  There's five answers in the thread that I linked you. You need the second answer. Btw; Iḿ using the same tools as you are to come up with an answer :)

                  Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

                  A 1 Reply Last reply
                  0
                  • L Lost User

                    There's five answers in the thread that I linked you. You need the second answer. Btw; Iḿ using the same tools as you are to come up with an answer :)

                    Bastard Programmer from Hell :suss: if you can't read my code, try converting it here[^]

                    A Offline
                    A Offline
                    a fatemeh
                    wrote on last edited by
                    #9

                    :) 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;

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups