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
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.