Log in

View Full Version : Can't send keystroke ?


rubik
November 21st, 2001, 00:21
Question : if i send a keystroke (postmessage->VK_A) to a particular application's window, and it doesn't seem to be doing anything with it (it is suppose to, if i hit A on the keyboard, it does something) , what does that really mean ? does the app somehow know i'm sending it messagers and not accepting it ?

My code works fine, i use findwindow to get the handle to the window i want to send the keystrokes to. If i select, let's say, notepad's window and test my code, it does exactly what i want, but when i use the handle of this app i want to debug, it seem to discard it. Help !

More information on this particular application. What it does when i run the exe is, it launches a DLL and it looks like the entire program is running in the DLL, and by sending keystrokes to thw exe window, it does not pass it down to the DLL. Help !

Carpathia
November 21st, 2001, 06:41
You didnt saywhat windows message you were using, but dont forget the response might be due to WM_KEYDOWN, WM_KEYUP, not just WM_CHAR.

Carpii

rubik
November 21st, 2001, 11:45
I am sending the correct WM_CHAR messagers, i've tested it on other applications, they receive it just fine. Is there a way for me to send it directly to the process instead of it's parent window, which seems to be dropping it ?

Carpathia
November 21st, 2001, 12:53
The point I was trying to make, is that WM_CHAR message is typically formed by an application calling TranslateMessage API, after a WM_KEYDOWN and corresponding WM_KEYUP message has been received. If the application is doing whatever is does by handling the actual WM_KEYUP or WM_KEYDOWN message, then manually sending a WM_CHAR message may not trigger the handler you are trying to invoke.

Sending a message to a process makes no sense. They must be sent to a Window with a valid HWND. Also, there is no practical way for the app to determine if the message originated from the keyboard handler or from your little test app.

Regards

Carpathia

rubik
November 21st, 2001, 12:56
I have also tried to send keydown+keyup messagers, with the same effect, works on all other apps except this one i'm debugging. So basically i'm stumped, how come this app doesn't respond to my key messagers ? I also checked the return value and it was successful. I used sendmessage, postmessage, postthreadmessage , all to the same effect. This app run fullscreen btw. Is there anything you can think of ?

Lord_Soth
November 21st, 2001, 13:05
How about you try and dig into the code that handles
keypresses in your program ??
See what kind of message it processes.

For a C based program, this is most easily done, breaking
inside the window procedure.
For an MFC program, it's a bit trickier. There is a function
for every message, assuming the programmer overide
it. (for example: OnKeyDown).
First check how the app is processing keystrokes, then
try to use the appropriate message and format.
It should work, unless there is more validation that
we are not aware of..

LS

Idcrisis
November 26th, 2001, 04:17
Downlod The Customiser from Wanga International and send all the API calls that you want to manually and visually before doing anything programmatically. It will be a great help.