문제

Is there a method for setting up a listener/watcher to know when an unrelated application window is closed?

I can check to see if the window is still open, but that seems silly to continually do.

도움이 되었습니까?

해결책

The Accessibility API's SetWinEventHook filtering for EVENT_OBJECT_DESTROY.

This is notification based so no polling and unlike a CBT hook does not require injection.

다른 팁

You can:

  1. poll for HWND validity (esp. if you don't need timing precision)
  2. subclass the window to intercept its WM_DESTROY and then forward the notification to your app
  3. install a window message hook to be able to intercept the message otherwise
  4. create a hidden child window to get it destroyed with the parent destruction, to also have your message handler called on time for you
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top