简体   繁体   English

ia如何通过使用窗口句柄或id获得进程窗口名称和主标题名称?

[英]How do i a get a process window name and maintitlename by using the window handle or id?

In a button click event IEnumerable res; 在按钮中单击事件IEnumerable res;

System.Threading.Thread.Sleep(10000);
var windows = FindWindowsWithText("GrADS 2.0.2.oga.2");
GetWindowThreadProcessId(windows,out res)

Then FindWindowsWithText 然后找到WindowsWithText

public static IEnumerable<IntPtr> FindWindowsWithText(string titleText)
        {
            return FindWindows(delegate(IntPtr wnd, IntPtr param)
            {
                return GetWindowText(wnd).Contains(titleText);
            });
        }

Then in the variable windows i'm getting one count in this case and the handle number: [0] = 3343352 然后在这种情况下,在变量窗口中我得到一个计数和句柄号:[0] = 3343352

With this number 3343352 i need to find in the end the process in this case external process name and process mainwindowtitle. 我需要使用这个号码3343352在此情况下最终找到该进程的外部进程名称和进程mainwindowtitle。

Using this 使用这个

IEnumerable<IntPtr> res;

Not sure if it's any good i thought to get the id and then somehow using the id to get the name and mainwindowtitle. 我不确定是否想获取ID,然后以某种方式使用ID来获取名称和mainwindowtitle。 I made a mess. 我一团糟。

Simply use process = Process.GetProcessById(id) to get the process by the ID. 只需使用process = Process.GetProcessById(id)即可通过ID获得流程。 Then you can use process.MainWindowTitle and process.ProcessName . 然后,您可以使用process.MainWindowTitleprocess.ProcessName

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何通过提供正在运行的进程名称来获取窗口句柄? - How to I get the window handle by giving the process name that is running? 你如何在 C# 中获得进程的主窗口句柄? - How do you get a Process' main window handle in C#? 如何找到正在运行的进程的窗口句柄? - How do I find the window handle for a running process? 如何获取 Word 应用程序的 Hwnd/进程 ID,并将其设置为前台窗口 - How do I get the Hwnd / Process Id for a Word Application, and set as Foreground Window 如何通过进程 ID 而不是窗口句柄向特定进程发送消息? - How can I send a message to a specific process by process id rather than by window handle? 如何获取进程窗口句柄intptr并将进程窗口保存到图像文件? - How can i get ap rocess window handle intptr and save the process window to image file? 如何从进程 ID 或进程名称获取 window 处理程序(另一个程序的)? - How to get window handler (of another program) from Process ID or Process Name? 隐藏窗口时如何获取Process.MainWindowHandle - How do I get the Process.MainWindowHandle when window is hidden 您如何找到哪个窗口(句柄)具有流程所有权? 并得到它的句柄..? - how do you find what window(Handle) takes process ownership? And get the handle for that..? 如何获取控制台应用程序窗口的句柄 - How do I get the handle of a console application's window
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM