I'm trying to build a automation tool...one function should send several
keystrokes to a active window..
but my problem is how you see:
keybd_event('VK_BACK',0,0,0); // ---> only one parameter is allowed !!
where can I put the other keystrokes ??
For example I got a combination of "CTRL + C" (copy action) and directly
after it a "CTRL + V" (past action)
hope someone can help...?
Oren
because I have to send application specific hotkey-keystrokes..for other
example:
CTRL + F (File open...)
or
ALT + S (for choosing a command that beginns with &S below a menu...)
Understand the problem...? :-)
Oren
> keybd_event('VK_BACK',0,0,0); // ---> only one parameter is allowed !!
>
> where can I put the other keystrokes ??
You have to make multiple calls to keybd_event(), one for each key, and one
for each individual KeyDown and KeyUp action as well. For example:
keybd_event(VK_CONTROL, 0, 0, 0);
keybd_event('C', 0, 0, 0);
keybd_event('C', 0, KEYEVENTF_KEYUP, 0);
keybd_event(VK_CONTROL, 0, KEYEVENTF_KEYUP, 0);
> For example I got a combination of "CTRL + C"
> (copy action) and directly after it a "CTRL + V" (past action)
Why not just send WM_COPY and WM_PASTE messages to the foreground window
instead?
Gambit
> because I have to send application specific hotkey-keystrokes..
CTRL-C and CTRL-V are hardly application-specific.
for other
> example:
>
> CTRL + F (File open...)
> or
> ALT + S (for choosing a command that beginns with &S below a menu...)
There are better ways to accomplish that, such as sending WM_COMMAND
messages instead. Dropping down to the keydb_event() is not a very reliable
way to accomplish things. Besides, if the focus ever shifts to another
window while you are still outputing keystrokes, then some strokes will go
to one window while other strokes go to the new window instead. Sending
messages is more reliable as you can obtain the desired HWND ahead of time
and send everything to that same HWND regardless of focus.
Gambit