How to get process name and title of the top window on Windows / C#

前端 未结 4 564
故里飘歌
故里飘歌 2020-12-31 14:44

As in the topic... or better - how to get this information from events when the top window changes?

4条回答
  •  滥情空心
    2020-12-31 15:20

    For the window title, you'll have to do a P/Invoke of GetWindowText with the HWND returned from GetForegroundWindow().

    As for the process info, I believe that P/Invoking GetWindowModuleFileName should work.

提交回复
热议问题