如何在 VBScript 中获取/设置每个应用程序窗口的位置和大小? [英] How to get/set each applications window position and size in VBScript?

查看:30
本文介绍了如何在 VBScript 中获取/设置每个应用程序窗口的位置和大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想编写一个脚本来组织我当前在屏幕上打开的窗口.

I'd like to write a script to organize the windows I currently have open on my screen.

例如:将所有浏览器移至监控 1,将其他所有浏览器移至监控 2例如:使显示器 1 上的 4 个最大化窗口在屏幕上占据相同大小的象限等等.

Ex: Move all browsers to monitor 1 and everything else to monitor 2 Ex: Make the 4 maximized windows on monitor 1 each take up equal sized quadrants on the screen etc..

我认为 VBScript 对此有好处吗?在 Win7 环境中,我会为此使用哪些对象?

I assume VBScript would be good for this? What Objects would I use for this in a Win7 environment?

推荐答案

这在开箱即用的 VBScript 中是不可能的,因为它不提供对用于窗口管理的 Windows API 的访问.

This isn't possible in VBScript out-of-the-box, because it doesn't provide access to Windows APIs used for window management.

AutoIt 似乎是完成这项工作的更好工具.查看以下函数和宏:

AutoIt seems a better tool for the job. Look into the following functions and macros:

  • WinMove - 移动窗口
  • _WinAPI_GetSystemMetrics(80) - 获取监视器的数量
  • @DesktopWidth@DesktopHeight - 主显示器像素大小
  • _WinAPI_GetSystemMetrics(78)_WinAPI_GetSystemMetrics(79) - 完整的桌面宽度和高度
  • WinMove - move windows
  • _WinAPI_GetSystemMetrics(80) - get the number of monitors
  • @DesktopWidth and @DesktopHeight - primary monitor pixel size
  • _WinAPI_GetSystemMetrics(78) and _WinAPI_GetSystemMetrics(79) - full desktop width and heigth

如果显示器尺寸不同,可以使用WMI类Win32_DesktopMonitor 及其 ScreenWidthScreenHeigth 属性以获取单个监视器尺寸.

If the monitor dimensions are different, you can use the WMI class Win32_DesktopMonitor and its ScreenWidth and ScreenHeigth properties to get individual monitor dimensions.

这篇关于如何在 VBScript 中获取/设置每个应用程序窗口的位置和大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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