Thread: [Help]Using keybd_event

  1. #1
    Registered User
    Join Date
    Feb 2011
    Posts
    4

    [Help]Using keybd_event

    I want to know if its possible to send keystrokes only to determined process, in my program Im using :

    keybd_event(xxxx,xxxx,0 , 0); // Press
    keybd_event(xxxx,xxxx, KEYEVENTF_KEYUP,0); // Release
    Its working perfectly, but I want to send keystrokes even if the process is minimized.

    Example:
    The program have to send keystrokes to Microsoft Word process, but Im browsing using mozzila at the moment, so Microsoft Word is minimized. I dont want to change the window.

    Thanks

  2. #2
    Registered User
    Join Date
    Aug 2010
    Location
    Poland
    Posts
    733
    http://msdn.microsoft.com/en-us/libr...(v=vs.85).aspx

    To acquire thread ID you can use:
    GetWindowThreadProcessId() and FindWindow().
    Or at first find process and then appropriate thread.

    keybd_event() is deprecated, use SendInput.

  3. #3
    Registered User
    Join Date
    Feb 2011
    Posts
    4
    I tried so many things,

    PostThreadMessage(dwPID, WM_KEYDOWN, VK_NUMPAD1, 0);
    PostThreadMessage(dwPID, WM_KEYUP, VK_NUMPAD1, 0);
    Can you give one right example using VK_NUMPAD1 ?

    About the GetWindowThreadProcessId() and FindWindow(), I already know how to use.

    EDIT: I tried to use SendInput and only send keys in windows that is focus.
    Last edited by Loose; 02-06-2011 at 03:34 PM.

Popular pages Recent additions subscribe to a feed