How can I tell if a process has a graphical interface?

前端 未结 4 963
夕颜
夕颜 2021-01-11 16:16

I\'m using automation to test an application, but sometimes I want to start the application via a batch file. When I run \"process.WaitForInputIdle(100)\" I get an error:

4条回答
  •  生来不讨喜
    2021-01-11 16:54

    See Environment.UserInteractive. That will identify whether the process has an interface at all, e.g. services are not user interactive.

    You could also look at Process.MainWindowHandle which will tell you whether there is a graphical interface.

    A combination of these two checks should cover all the possibilities.

提交回复
热议问题