获取一个窗口与不完全了解称号手柄。 (C#) [英] Get the handle of a window with not fully known title. (C#)

查看:104
本文介绍了获取一个窗口与不完全了解称号手柄。 (C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

标题是带有可变的后缀部分是静态的。例如*窗口标题{ - USER_ID}*。

The title is partially static with an variable suffix. For example *"Window Title {- user_id}"*.

我怎样才能不知道确切的标题手柄?

How can I get the handle without knowing the exact title?

推荐答案

看通过所有的进程,并检查<一个href=\"http://msdn.microsoft.com/en-us/library/system.diagnostics.process.mainwindowtitle.aspx\">MainWindowTitle. (您可以使用正则表达式,或 StartsWith 等)

Look through all the Processes and check the MainWindowTitle. (You can use regexps, or StartsWith, etc)

foreach(Process proc in Process.GetProcesses())
{
   if(proc.MainWindowTitle.StartsWith("Some String"))
   {
      IntPtr handle = proc.MainWindowHandle;
      // ...
   }
}

这篇关于获取一个窗口与不完全了解称号手柄。 (C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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