0

I'm making a program which sends a specified line of text to the active window when you press a specified hotkey.

I've figured out how the hotkey part, but have no idea on how to send the text to the active window.

does anyone give me some ideas on this?

i'm using visual C++ .net


thanks

2
Contributors
1
Reply
3
Views
11 Years
Discussion Span
Last Post by BountyX
1

Use PostMessage() . It will add your message to the the recieving windows message que.

(SendMessage is to be used only within the same thread).

Also, check out SendThreadMessage considering that PostMessage returns immediately so you can't get the return code from the message.

You may need the window's HWND as a parameter. To get the target process HWND try FindWindow or module walk through a list of process id's then get the HWND from the id.

If the recieving window is already active, you can do the following using keybd_event:

keybd_event( 'A', 0, 0, 0 );
keybd_event( 'A', 0, KEYEVENTF_KEYUP, 0 );

If you have the target process HWND, then you can set the window acive then use keybd_event (however it is better to use PostMessage if you have the hwnd -- that way if focus is somehow interupted it will not cause any problem)

For information on function prototypes reference msdn.com and search for the function name or keyword (i.e. PostMessage, keybd_event, module walking, etc)

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.