CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Sendkey to apps

  1. #1
    Join Date
    Nov 2003

    Sendkey to apps

    Hi All,

    I downloaded an app from a coding site to help me understand sending keystrokes to other apps, but I am having trouble with one aspect that is not included in the code.

    Once I send the keystrokes to my target app I lose the focus on the sendkeystoapps application. I need to be able to send keys to another application, then wait a few minutes for them to be executed, then return to my app to perform further funtions. Is this even possible?

    The sendkeystospps project can be found at http://codepaste.ru/3381/

    Note: The sendkeystoapps is not my code. I am using it as a learning tool.

    Thank you
    Last edited by LTLhawk; January 23rd, 2011 at 01:20 PM.

  2. #2
    Join Date
    Jul 2009

    Re: Sendkey to apps

    you can use this piece of code after grabbing the window handle of the desired window.

      ::SendMessage(hwnd, WM_SYSCOMMAND, SC_HOTKEY, (LPARAM) hwnd);
      ::SendMessage(hwnd, WM_SYSCOMMAND, SC_RESTORE, (LPARAM) hwnd);
      ::ShowWindow(hwnd, SW_SHOW);

  3. #3
    Join Date
    Nov 2003

    Re: Sendkey to apps

    YEs...thank you..

  4. #4
    Join Date
    May 1999

    Re: Sendkey to apps

    I would advise to use PostMessage instead SendMessage. If receiving application is ill behaving it may put your application into a zombie state.

    Another advice is to use SendInput Function that synthesizes keystrokes and mouse action (movements, and button clicks).

    All of the above would be helpful to you if you were in the right forum. It is a C++ forum not C#.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.