Windows API: handling keypress event of external window application through C#

后端 未结 1 851
青春惊慌失措
青春惊慌失措 2021-01-06 21:03

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

相关标签:
1条回答
  • 2021-01-06 21:18

    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.

    0 讨论(0)
提交回复
热议问题