views:

43

answers:

1

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.

A: 

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.

ho1