-
June 9th, 2001, 02:52 AM
#1
keybd_event question
I am launching console app from within this program and trying to send a required keypress using keybd_event to the launched program, but for some reason, this is not working
#include <windows.h>
void main( void )
{
WinExec("program.exe",NULL); // for simplicty
keybd_event(65,NULL,0,0); // key down "A"
keybd_event(65,NULL,KEYEVENTF_KEYUP,0); // key up "A"
}
the program requires an "A" to run, shouldn't this code provide it? In debug, if I remove the Winexec call, the keybd_event is entering an "A" into the source editor.
-
June 9th, 2001, 02:55 AM
#2
Re: keybd_event question
Well you have two problems.
1. The program takes a minute to start up
2. The program might not have focus
In order to fix the first one, you could use Sleep() to wait a few seconds before sending the 'A'. For the second problem, you should use SetForegroundWindow(). In order to pass that function the HWND that it needs, you will need to use FindWindow() to get a handle on program.exe.
Not sure if that will help you... But that's one method you can use to do this.
Good luck!
John Peloquin
Peloweb.com
john@peloweb.com
-
June 9th, 2001, 11:44 AM
#3
Re: keybd_event question
I did try the sleep thing before posting (didnt work) but not FindWindow/SetForegroundwindow.
The problem seems to be that "program.exe" cannot
be run in a window and forces fullscreen.
Is it possible to get a handle on an app that is running fullscreen ?
Is there any way around this ???
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
|