-
January 23rd, 2011, 02:16 PM
#1
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.
-
January 24th, 2011, 05:42 AM
#2
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);
-
January 24th, 2011, 05:49 PM
#3
-
January 27th, 2011, 08:59 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|