获取标题不完全已知的窗口句柄.(C#) [英] Get the handle of a window with not fully known title. (C#)
本文介绍了获取标题不完全已知的窗口句柄.(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?
推荐答案
查看所有进程并检查 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屋!
查看全文