获取位置使用.NET所有打开的窗口和大小(C#) [英] Get location and size of all open windows using .NET (C#)

查看:134
本文介绍了获取位置使用.NET所有打开的窗口和大小(C#)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法来检测和保存所有打开的窗口的位置和大小,以及它们的状态(最小化,最大化等)

Is there a way to detect and store the location and size of all open windows, as well as their state (Minimized, Maximized etc)

我从来没有开发任何东西,得到这样从实际操作系统的信息。是否需要调用一个Windows API和包括非托管的code?

I've never developed anything that gets information from the actual operating system in this way. Does it require a call to a Windows API and involve unmanaged code?

如果这一点不明确,请评论,我会尽量详细说明。

If this is not clear please comment and I will try to elaborate.

推荐答案

通话 EnumWindows的通过所有的窗户的循环,然后调用 GetWindowPlacement 脱身的信息。这将需要的PInvoke到Windows API,但它并不难,只要能找到在的PInvoke 网站的所有信息。

Call EnumWindows to loop through all the windows, then call GetWindowPlacement to get out the information. It will require PInvoke to Windows API, but it's not that difficult, just can find all the information at the PInvoke site.

顺便说一句,这里是找到一个特定的窗口,并得到一个 $ C $的CProject 文章/设置它的显示状态,可能是一个很好的出发点(code是在VB.Net,但你很可能只是使用在线VB.Net到C#转换器之一,如果你不知道VB。网)

Btw, here's a codeproject article for finding a specific window and getting/setting the show state of it, might be a good starting point (the code is in VB.Net, but you could probably just use one of the online VB.Net to C# converters if you don't know VB.Net)

这篇关于获取位置使用.NET所有打开的窗口和大小(C#)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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