The problem:

I have a problem realizing a keyboard hook which should fill the activated
edit field in the active window with defined content.

To reach this a windows message WM_SETTEXT is sent to the active
edit field (in which the cursor is placed).

There are the 3 essential code lines in the hook-DLL:

invoke GetFocus
mov hFocus,eax
invoke SendMessage, hFocus, WM_SETTEXT, 0, ADDR szText

This seems to work fine with NOTEPAD, WORDPAD, EXCEL, IE a.s.o. But not in
WORD!

In WORD, the messages affect only combo-boxes, but not the "text-window".
Possibly GetFocus returns the wrong handle ?!?


Thank you for your help.
Posted on 2004-05-24 05:43:56 by Mainframe
I came across a similar problem a while back I think - I was trying to send bits of text to other active applications and the WM_SETTEXT message was the first thing I tired (unsucessfully). After that I tried sending the keystrokes with SendInput - worked ok - but on long strings of text it tended to overload the keyboard buffer.

The best way I found was to use a WH_JOURNALPLAYBACK hook and send the keystrokes as WM_CHAR messages which has worked really well.

Hope this helps

Mark
Posted on 2004-05-24 13:02:23 by MurkyT