我怎样才能知道,如果一个进程有一个图形界面呢? [英] How can I tell if a process has a graphical interface?

查看:1690
本文介绍了我怎样才能知道,如果一个进程有一个图形界面呢?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用自动化测试应用程序,但有时我想开始通过批处理文件的应用程序。当我运行process.WaitForInputIdle(100)我得到一个错误:

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:

。WaitForInputIdle失败这可能是因为该进程没有图形界面

"WaitForInputIdle failed. This could be because the process does not have a graphical interface."

我如何判断的过程中有一个图形界面或不?

How can I tell if the process has a graphical interface or not?

推荐答案

请参阅 Environment.UserInteractive 。这将确定该进程是否有一个接口在所有的,例如服务不与用户进行互动。

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

您也可以看看的 Process.MainWindowHandle 它会告诉你是否有图形界面。

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.

这篇关于我怎样才能知道,如果一个进程有一个图形界面呢?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆