Post Reply

Forums -> UltraMon™ SDK -> Moving open applications to a different monitor
tony   2005-10-17 03:09
Hi there,
I just discovered ultramon and am wondering how to move an open app to a different window using scripting.
I know there is this function through the toolbar button, but with more than two monitors, this requires shuffling across the list of available monitors.
With great programs that can skin buttons directly onto the taskbar (Windowblinds), it is possible to put four new buttons, and just hit the one i want.
Is there a way to do this?
BTW, I'm not a scripting guru, I'm a writer.
Christian Studer   2005-10-17 09:20
I have uploaded a script which does this: MoveActiveWnd

The script accepts the monitor number as an argument. For example to move the active window to monitor 1, you would run the script like this:

MoveActiveWnd.vbs 1

If your monitors use different resolutions, the script will by default resize the window proportionally.

To only resize the window if necessary (resize to fit), you'll need to add the /r command line argument:

MoveActiveWnd.vbs 1 /r

Christian Studer -
tony   2005-10-18 04:12
Thankyou Christian,
It seems that windowblinds can only accept an .exe file for its button applications.
I have been able to get this working using an autoit script compiled to an exe to drive the .vbs.
Unfortunately I don't know enough about how its done to convert the formats between the scripting languages.
So thankyou for your rapid reply.
If I might ask a further question, how would I get the vbs script to check to see whether the window is actually currently on the monitor that I am trying to send it to.
I mean, if I put four buttons in my titlebar, and the one for the monitor the app is on gets clicked, can I filter that out? Its only a little thing, so not worth extended effort.
PS: I'm using Objectdock. I wish it had a feature like your smart taskbar. That's a cool idea.
Christian Studer   2005-10-18 09:42
If the window is already on that monitor, nothing should happen when you run the script.

Let me know if that's not the case on your system, adding a check for the current monitor would be no problem.

Running the script like this might also work with WindowBlinds:

wscript.exe "C:\My Scripts\MoveActiveWnd.vbs" 1

Christian Studer -
tony   2005-10-19 05:11
No, nothing happens if the same window is chosen.
And you are right. its a waste of effort to check.
I tried the wscript command in starskin/windowblinds, but it doesn't do anything. so I have the following - which I know is exactly the same - running as a compiled autoit script and attached to the buttons. A different one for each, of course.
run ("wscript.exe d:\WinProgs\ultramon_scripts\moveactivewnd.vbs 1")
Notice the NO spaces. This was the only way it would work.
This setup works fine. So now I have a row of buttons in my titlebar which persist for all applications. I just click which one I need for which window, and the app jumps to that monitor.
It looks like Ultramon will be useful for me. I have been dragging the windows about. Which works. I'm still wondering about Objectdock. Its terribly resource hungry, and sometimes swallows all the cpu even on a 3500 AMD64. And its not smart taskbar aware. Even if it is pretty.
Thanks for your help.
tony   2005-10-19 05:17
Oh, and BTW, this is working with the freeware versions of Windowblinds and Starskin, so anybody can do it.
And the command I have on my starskin button looks like this:
Of course, a different exe for each button. And as I said, the exe is just the compiled autoit script pointing at MoveActiveWnd.vbs.
Autoit is also freeware. So anyone with Ultramon can make these buttons work.
Joshua C   2007-09-23 08:35
tony said:
"run ("wscript.exe d:\WinProgs\ultramon_scripts\moveactivewnd.vbs 1")
Notice the NO spaces. This was the only way it would work."

If a path has spaces in it (e.g. C:\My Documents), then you need to put the path on quotes, e.g. "C:\My Documents". It looks like you'd need two sets of quotes in your example, like this:

run ("wscript.exe "C:\My Documents\MoveActiveWnd.vbs" 1")

The whole thing has to be on quotes (I guess) because it's a string. You need another set of quotes around the path with spaces. Note, however, that paths without spaces should never need quotes.

dssamusaran   2009-03-15 09:01

I don't understand how Straskin or WindowBlinds enable you to add buttons directly on the titlebar of each application...

I'm interested to use this script exactly this way.

Does someone know how to do it?
backspace   2009-10-09 23:09
hi,I wrote a application that has 5 separate forms. I want a script to move these 5 forms to our 5 Monitors. my Application runs at startup and these 5 forms should move automatically. thanks
Christian Studer   2009-10-10 11:35
Can you modify the application? If yes, you could position the forms directly from within the application, no script needed.

Christian Studer -
backspace   2009-10-11 15:58
thanks Christian, but how can i position the forms directly from my application.
please guide me.
Christian Studer   2009-10-12 08:27
What language are you using (VB, VB.NET, C#, etc)?

Christian Studer -
backspace   2009-10-17 19:18
i use c#.
Christian Studer   2009-10-18 07:56
Here's sample code which moves the form to the top-left corner of monitor 2 in the form's OnLoad event handler:private void Form1_Load(object sender, EventArgs e) { ULTRAMONLib.UltraMonSystemClass sys = new ULTRAMONLib.UltraMonSystemClass(); ULTRAMONLib.IUltraMonMonitor mon = sys.Monitors.Item("2"); this.Left = mon.Left; this.Top = mon.Top; }You'll need to add a reference to the UltraMon type library to your project for the code to work.

Christian Studer -
Jon Zadra   2010-02-18 08:13
Since it's been 5 years since this solution was posted... is it still the best option (as far as having a title bar button that moves a window to a specific monitor, rather than presenting a list of all for a 3+ monitor system)?

I don't see a hotkey option in UltraMon 3. Just the shortcuts option. But this doesn't provide a way to map to a key or add a button.

By the way, I think this would be a great feature to add in the default tools for UltraMon, especially now that people are commonly using more than 2 monitors.

Christian Studer   2010-02-19 07:31
Support for this will be considered for a future release. You can configure hotkeys via UltraMon Options > Hotkeys ('Run application or script' action).

Christian Studer -
Jon Zadra   2010-02-20 06:15
Forums -> UltraMon™ SDK -> Moving open applications to a different monitor

Post Reply