[Help]Using keybd_event

This is a discussion on [Help]Using keybd_event within the C++ Programming forums, part of the General Programming Boards category; I want to know if its possible to send keystrokes only to determined process, in my program Im using : ...

  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
    682
    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.
    I never put signature, but I decided to make an exception.

  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 02:34 PM.

Popular pages Recent additions subscribe to a feed

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