Thread: Trouble with simulating keystrokes

  1. #1
    Android geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470

    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.
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur 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 geek@02's Avatar
    Join Date
    Mar 2004
    Location
    Kurunegala Colony, Sri Lanka, Sri Lanka
    Posts
    470
    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?
    GameJolt: https://gamejolt.com/@KasunL
    Game Development Youtube:
    https://is.gd/XyhYoP
    Amateur IT Blog: http://everything-geeky.blogspot.com/



    (and, sorry for my amateur 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, 10: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, 10: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, 08:08 AM