Trouble with simulating keystrokes

This is a discussion on Trouble with simulating keystrokes within the Windows Programming forums, part of the Platform Specific Boards category; Hi! i'm trying to simulate key presses and i did this: Code: keybd_event('G', NULL, KEYEVENTF_EXTENDEDKEY | 0, 0 ); it ...

  1. #1
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    386

    Trouble with simulating keystrokes

    Hi!
    i'm trying to simulate key presses and i did this:

    Code:
    keybd_event('G', NULL, KEYEVENTF_EXTENDEDKEY | 0, 0 );
    it wrote lowercase 'g' into notepad, not the uppercase 'G' that i've passed into the function. and when i pass the lowercase:

    Code:
    keybd_event('g', NULL, KEYEVENTF_EXTENDEDKEY | 0, 0 );
    it writes '7', not 'g'?
    So why is this happening? how can i correctly simulate key strokes?

    Thanks for any help.
    Last edited by geek@02; 03-08-2006 at 07:55 AM.
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  2. #2
    Confused Magos's Avatar
    Join Date
    Sep 2001
    Location
    Sweden
    Posts
    3,145
    MagosX.com

    Give a man a fish and you feed him for a day.
    Teach a man to fish and you feed him for a lifetime.

  3. #3
    Android
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    386
    u mean, use SendInput() instead of keybd_event()? but i can use only keybd_event() right now. so keybd_event() isn't capable of doing it?
    Some useless programs i've wrote : slprogrammersheaven
    Youtube: http://www.youtube.com/user/geekyzine
    My amature IT Blog: http://everything-geeky.blogspot.com/
    My Flash games: http://flashweed.blogspot.com/

    (and, sorry for my amature english)

  4. #4
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Well, I don't see why you need to use keybd_event, but the first argument to it is:

    Code:
    BYTE bVk
    Which specifies the virtual key code. Look at them here: http://msdn.microsoft.com/library/de...alKeyCodes.asp

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Trouble with assignment in C
    By mohanlon in forum C Programming
    Replies: 17
    Last Post: 06-23-2009, 11:44 AM
  2. Fake keystrokes to another process
    By Nota in forum Windows Programming
    Replies: 20
    Last Post: 01-26-2009, 11:56 PM
  3. Sending keystrokes to another view
    By azeemanwer in forum C++ Programming
    Replies: 2
    Last Post: 08-28-2007, 11:41 AM
  4. Send keystrokes to a running program via batch file
    By ganjamon in forum Windows Programming
    Replies: 2
    Last Post: 08-16-2005, 09:08 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21