如何编写脚本来组织我的桌面窗口? (WinXP)

发布于 2024-09-27 19:12:40 字数 469 浏览 2 评论 0原文

我想编写一个脚本,将当前打开的窗口移动到某个位置。

理想情况下,我的程序如下所示:

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

空城缀染半城烟沙 2024-10-04 19:12:40

我认为您正在寻找 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.

素罗衫 2024-10-04 19:12:40

如果您正在寻找易于编码的东西,您可以使用 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.

蓦然回首 2024-10-04 19:12:40

您可能还想了解一下 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文