如何编写脚本来组织我的桌面窗口? (WinXP)
我想编写一个脚本,将当前打开的窗口移动到某个位置。
理想情况下,我的程序如下所示:
var window = FindWindow("Winamp");
window.setPos(1140, 900, 160, 124); // set x, y, width and height
window = FindWindow("Windows Live Messenger");
window.setPos(1140, 0, 900, 124);
// etc...
我怀疑我需要使用 Windows 脚本主机。我查看了 MSDN 上的文档,但似乎找不到我需要的 API 调用。
有人能指出我正确的方向吗?
PS:不一定是脚本语言,C++也可以。
I would like to write a script that moves the currently open Windows to a certain location.
Ideally, my program would look like this:
var window = FindWindow("Winamp");
window.setPos(1140, 900, 160, 124); // set x, y, width and height
window = FindWindow("Windows Live Messenger");
window.setPos(1140, 0, 900, 124);
// etc...
I suspect that I need to use the Windows Scripting Host. I had a look at the documentation on MSDN, but I can't seem to find the API calls that I need.
Can someone point me in the right direction?
PS: It doesn't have to be a scripting language, C++ is fine as well.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为您正在寻找 SetWindowPos。这是一篇 CodeProject 文章,据说(我没有仔细查看代码)展示了如何从 vbscript 使用它: 移动无边框窗口 - 另一种方式
另外,还有一种FindWindows 将是 EnumWindows,如果您没有使用
FindWindows
所需的确切信息,而是想要获取所有窗口的列表,然后您的代码可以选择最合适的窗户。I think you're looking for SetWindowPos. Here's a CodeProject article that supposedly (I haven't looked carefully at the code) shows how to use it from vbscript: Moving a borderless window - an alternate way
Also, an alternative to FindWindows would be EnumWindows, which can be useful if you don't have the exact information needed to use
FindWindows
and would instead want to get a list of all windows and your code could then select the most suitable window.如果您正在寻找易于编码的东西,您可以使用 AutoIt,可在此处找到: http:// www.autoitscript.com/autoit3/index.shtml。我个人没有使用过它,但它似乎能够实现你想要的,甚至更多。
If you're looking for something easy to code, you can use AutoIt, available here: http://www.autoitscript.com/autoit3/index.shtml. I have personaly not used it, but it seems to be able to achieve what you want, and more.
您可能还想了解一下 AutoHotKey。我自己只用它来做一些非常基本的事情。但我知道它具有相当复杂的脚本编写能力。
You might also want to look into AutoHotKey. I have only used it for some very basic things myself. But I know it has pretty sophisticated scripting abilities.