Windows API: handling keypress event of external window application through C#
I have one external application window opened. Through my winform application, i want to execute certain code when keypress event happens on this external window.
I know window handle of this external application window.
Any help will be truely appreciated.
开发者_如何学GoThanks,
One way to do this is to set up a hook on the external application window with SetWindowHookEx. Then monitor the WM_KEYDOWN message.
I am actually not sure that it will work in C# because the hook callback has to be in a native DLL. You might have to write a portion of the solution in an unmanaged language.
Alternatively, you could use a global keyboard hook, possibly combined with a check of the currently active window.
精彩评论