获取运行过程的尺寸 [英] Get a running process' dimensions
本文介绍了获取运行过程的尺寸的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试获取应用程序中特定x,y位置的屏幕截图.有什么方法可以在Process对象中获取正在运行的应用,然后获取其尺寸?
I'm trying to grab a screen shot of a specific x, y location in an application. Is there any way to get a running app in a Process object, then get the dimensions of it?
类似的东西:
Process[] processlist = Process.GetProcesses();
foreach (Process proc in processlist)
{
Console.WriteLine("Process: {0} ID: {1}", proc.Width, proc.Height);
}
推荐答案
可能有其他方法可以做到这一点,但这是一个快速的高级解决方案:
There are probably other ways to do this but here's a quick high level solution:
- 获取主窗口句柄( Process.MainWindowHandle).
- 使用win32 API函数获取窗口高度 GetWindowRect
对SO问题的答案显示了获取窗口大小然后进行设置.
This answer to a SO question shows getting the window size and then setting it.
我意识到这个答案假设该过程只有一个窗口.这样的 question/答案描述获取进程的所有窗口.
I realize this answer assumes that the process only has a single window. This SO question/answer(s) describes getting all of the windows for a process.
这篇关于获取运行过程的尺寸的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文