Thread: SendInput()

  1. #1
    Registered User
    Join Date
    Oct 2003
    Posts
    18

    SendInput()

    I'm trying to give keyboard input to a program that's using directinput.
    To do this I tried using SendInput, but I figured this doesn't really work.
    MSDN suggests adding KEYEVENTF_SCANCODE to the dwFlags but I get an undeclared identifier message when I try to compile:

    error C2065: 'KEYEVENTF_SCANCODE' : undeclared identifier

    Does anyone know what to do? Am I missing an include file or something?

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    Search your headers for it. If you don't have, then you'll need to download the latest Core SDK.

    Here is how it is defined in the latest SDK:
    Code:
    #if(_WIN32_WINNT >= 0x0500)
    #define KEYEVENTF_UNICODE     0x0004
    #define KEYEVENTF_SCANCODE    0x0008
    #endif /* _WIN32_WINNT >= 0x0500 */
    You could also try keybd_event().

    If that doesn't work, then you'll need to read the following technical article:
    Win32 Hooks
    You'll be interested in the WH_JOURNALPLAYBACK hook.
    From Win32 Hooks:

    Applications have used hooks to:
    • Simulate mouse and keyboard input (WH_JOURNALPLAYBACK). Hooks provide the only reliable way to simulate these activities. If you try to simulate these events by sending or posting messages, Windows internals do not update the keyboard or mouse state, which can lead to unexpected behavior. If hooks are used to play back keyboard or mouse events, these events are processed exactly like real keyboard or mouse events. Microsoft Excel uses hooks to implement its SEND.KEYS macro function.
    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Sending Strings using SendInput
    By TheWeird1 in forum Windows Programming
    Replies: 3
    Last Post: 07-04-2009, 10:35 PM
  2. Replies: 2
    Last Post: 03-23-2006, 07:08 AM
  3. SendInput()?
    By src in forum Windows Programming
    Replies: 11
    Last Post: 02-21-2003, 07:43 PM
  4. tagINPUT sendINput
    By Unregistered in forum Windows Programming
    Replies: 3
    Last Post: 03-09-2002, 06:14 PM
  5. tagINPUT and SendInput
    By Unregistered in forum C Programming
    Replies: 2
    Last Post: 03-08-2002, 03:08 PM