以编程方式找出进程是否需要用户输入 [英] Find out programmatically if a process is demanding user input

查看:28
本文介绍了以编程方式找出进程是否需要用户输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何以编程方式(在 C# 中)确定另一个外部应用程序(本机、java、.NET 或其他……)当前是否需要用户输入?这可以在托管代码中完全完成吗?

How can I programmatically (in C#) determine, if ANOTHER foreign application (native, java, .NET or whatever...) is currently demanding user input? Can this be done fully in Managed code?

我正在寻找的是实现:

static Boolean IsWaitingForUserInput(String processName)
{
    ???
}

要求用户输入是指当应用程序要求用户输入一些数据或退出错误消息(模态对话框)并且无法再执行其正常任务时.等待用户绘制某些内容的绘图应用程序在这里不具有任何意义.

By demanding user input I mean when an application asks the user to enter some data or quit an error message (Modal dialogs) and is not able to perform its normal tasks anymore. A drawing application that is waiting for the user to draw something is not meant here.

PS:经过编辑以反映底部的评论并使关注点更清晰,一些评论和答案可能与问题并非100%一致.在评估答案和评论时要考虑到这一点.

PS: After edits to reflect the comments at the bottom and make the concern clearer, some comments and answers may not be 100% consistent with the question. Take this into account when evaluating the answers and remarks.

推荐答案

这通常是不可能的.以一种常见的应用程序为例,文字处理器.如今,它将在后台运行拼写检查,它会定期自动保存您的文档等.然而,从用户的角度来看,它一直在等待输入.

It's in general impossible. Take for instance a common kind of application, a word processor. Nowadays that will be running spellchecks in the background, it periodically auto-saves your document, etcetera. Yet from a users perspective it's waiting for input all the time.

另一种常见情况是幻灯片查看器.您可以随时按下一个键来推进幻灯片.然而,您的典型用户不会将此视为等待输入".

Another common case would be a slideshow viewer. At any moment in time you could press a key to advance a slide. Yet your typical user would not view this as "waiting for input".

总结:等待输入"是一种主观状态,因此无法以编程方式确定.

To summarize: "waiting for input" is a subjective state and therefore cannot be determined programmatically.

这篇关于以编程方式找出进程是否需要用户输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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