Thread: keybd_event bug?

  1. #1
    Registered User
    Join Date
    Aug 2003
    Posts
    288

    keybd_event bug?

    When i try to send two letters using keybd_event:
    Code:
    keybd_event('m', 0, 0, 0);
    keybd_event('m', 0, KEYEVENTF_KEYUP, 0);
    
    keybd_event('n', 0, 0, 0);
    keybd_event('n', 0, KEYEVENTF_KEYUP, 0);
    i get:

    Instead of m, '-'
    Instead of n, '.'

    It send capital letters and numbers fine, but lower-case letters, and symbols dont work at all.

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Here is the list of Virtual-Key Codes.
    Notice that the alpha keyboard keys coorespond to uppercase ascii codes. So 'A' is the A keyboard key, which can be "a" or "A" depending on the state of the shift keys and caps lock key.

    Look at the example for keybd_event() to see how to get keyboard state information.

    gg

  3. #3
    Registered User
    Join Date
    Dec 2002
    Posts
    119
    so in other words send your kb_events to do this:
    1. Depress Shift key
    2. Depress A key
    3. Release A key
    4. Release Shift key
    If you speak or are learning Spanish, check out this Spanish and English Dictionary, it is a handy online resource.
    What happens is not as important as how you react to what happens. -Thaddeus Golas

  4. #4
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    What about for commas, exclamations, etc?

    I tried depressing "," and releasing it but i didnt get the comma

  5. #5
    C++ Developer XSquared's Avatar
    Join Date
    Jun 2002
    Location
    Ontario, Canada
    Posts
    2,718
    Did you completely ignore Codeplug's post?
    Naturally I didn't feel inspired enough to read all the links for you, since I already slaved away for long hours under a blistering sun pressing the search button after typing four whole words! - Quzah

    You. Fetch me my copy of the Wall Street Journal. You two, fight to the death - Stewie

  6. #6
    Registered User
    Join Date
    Aug 2003
    Posts
    288
    No i went to the links Codeplug provided, and the in the list of VK codes, the only "," I could see was one for Windows 2000/XP.

  7. #7
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    VK_OEM_COMMA (BC)
    Windows 2000/XP: For any country/region, the ',' key
    To me, that only implies that you're garenteed to ge a comma character regarless of the country/region, if its Win2k/XP. Doesn't say anything about it's lack of availability.

    I would try it out.
    Otherwise, you can use VkKeyScan() to get the correct virtual keycode and keyboard state for a character.

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Kernel bug? (attn matsp)
    By brewbuck in forum Linux Programming
    Replies: 7
    Last Post: 04-13-2009, 10:31 AM
  2. gaks bug?
    By Yarin in forum A Brief History of Cprogramming.com
    Replies: 5
    Last Post: 08-31-2008, 02:47 PM
  3. Debugging a rare / unreproducible bug..
    By g4j31a5 in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 08-05-2008, 12:56 PM
  4. Bug in iterator comparison in C++ standard?
    By steev in forum C++ Programming
    Replies: 14
    Last Post: 07-12-2008, 12:02 AM
  5. ATL bug of CComPtr?
    By George2 in forum Windows Programming
    Replies: 6
    Last Post: 04-07-2008, 07:52 AM