[comp.windows.misc] Activating a button with a key

jeff@cdp.UUCP (03/18/91)

I'm trying to figure out how to "stuff keystrokes" into Windows.
I've been able to successfully do this for edit controls, using
the obvious "send WM_CHAR" or "send WM_KEYDOWN, WM_KEYUP" sequences.
However, I'm stuck on how to activate a button by pressing a key.
I know this is possible, since the Recorder can do it with no
problem, but no matter where I send messages, nothing happens.
I've tried SPYing but that hasn't revealed any useful info.

Solutions or pointers would be appreciated.  Thanks...

	Jeff Dean
	jeff@cdp.igc.org
	uunet!pyramid!cdp!jeff

bonneau@hyper.hyper.com (Paul Bonneau) (03/21/91)

In article <1097300009@cdp> jeff@cdp.UUCP writes:
>
>I'm trying to figure out how to "stuff keystrokes" into Windows.
>I've been able to successfully do this for edit controls, using
>the obvious "send WM_CHAR" or "send WM_KEYDOWN, WM_KEYUP" sequences.
>However, I'm stuck on how to activate a button by pressing a key.
>I know this is possible, since the Recorder can do it with no
>problem, but no matter where I send messages, nothing happens.
>I've tried SPYing but that hasn't revealed any useful info.
>
Try PostMessage() instead of send.  This way WM_KEYDOWN and
WM_KEYUP messages will get translated by the call to
TranslateMessage() inside the message loop of the recipient.

Message that are sent (SendMessage()) do not go to the
application's message queue, and so do not get processed
by TranslateMessage().

cheers - Paul Bonneau.