Page 1 of 1

How to send keyboard input to other running program?

PostPosted: Jun 26, 2002 @ 9:53am
by Rayman
I would like to implement a function like this:
My program is running in the background, and register a hotkey associated with a hardware button. when the button was pressed, my program will send a "Ctrl+C" to the foreground program(for example PocketWord). the key function is like this:

void SendCtrlC()
{
keybd_event(...);
keybd_event(...);
...
Sleep(0);
}

The code works perfect under PPC 2002 emulator, but just won't work under my IPaq! Anyone can give me some hints?

PostPosted: Jun 26, 2002 @ 10:37am
by refractor

PostPosted: Jun 26, 2002 @ 11:42am
by Rayman

PostPosted: Jun 26, 2002 @ 12:07pm
by refractor
#2 Weird.

#3
Sorry about the GetActiveWindow thing - I didn't read the MSDN page properly :oops:

However, maybe:

HWND GetForegroundWindow(void);

Will give you the active window? It doesn't mention anything about it being thread-specific.

If it doesn't work, let me know and I'll see if it works on mine.

Why isn't a WM_COPY enough?

Cheers,

Refractor

PostPosted: Jun 26, 2002 @ 4:30pm
by Rayman