Detect if external process is interactive and has any visible UI

后端 未结 2 1229
不知归路
不知归路 2021-01-17 03:48

I cannot seem to find a way to determine whether a Process has a user interface e.g. a window, which is visible to the user?

  • Environment.UserInte
2条回答
  •  一整个雨季
    2021-01-17 04:12

    1. Find out the process ID from your Process instance.
    2. Enumerate the top-level windows with EnumWindows.
    3. Call GetWindowThreadProcessId and see if it matches the target PID.
    4. Call IsWindowVisible and/or IsIconic to test if that window is visible to the user.

提交回复
热议问题