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

Thread: Sendkey to apps

Hybrid View

  1. #1
    Join Date
    Nov 2003
    Posts
    41

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

  2. #2
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: Sendkey to apps

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

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

  3. #3
    Join Date
    Nov 2003
    Posts
    41

    Re: Sendkey to apps

    YEs...thank you..

  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    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
  •  





Click Here to Expand Forum to Full Width

Featured