Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending keystrokes (Part 2 ;-))

Status
Not open for further replies.

LuckyLuke

Programmer
Mar 28, 2001
188
NL
Hiya again,

OK, I've got the logging part to work (atleast, most of it) and now I want a fast way to send keystrokes and entire strings. So not with the sendkey command, because that's to slow... Is there a way I can do it like you add text to a textbox with the sendmessage call, it's like immediately there then... I have found an API call, but the only advantage over the sendkey command is that the Num Lock key doesn't flicker and you can 'hold' a key.

I was wondering if this is possible and I don't want to point it to a certain handle or something, I just want to send it to the active control or form or whatever is active ;-)

LuCkY
 
Sorry . . . you will still need a handle just because of the way Windows works. You will need the hWnd of the OCX,TextBox, etc. that you want to send the keystroke to. What you will do then is find that window's (remember that in Windows, every control is essentially a subclass of a window) message queue and use the SendMessage or PostMessage API to place the keystrokes in the queue.
Of course, if you didn't want to use the message queue directly, you might consider creating a COM interface on the target EXE to accept information for the activeX control from your program . . . that is of course assuming that you are writing the target EXE. This would probably be the fastest way.
I don't think that you will be able to directly communicate with the ActiveX control in another process by using its memory space (which is the only other option I can think of) since each process space is supposed to be oblivious to the other processes that are running . . . or at least in theory. - Jeff Marler B-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top