Post Reply

Forums -> UltraMon™ -> Anchoring a window to a corner...
Rob Perelman   2006-01-04 11:01
I needed to make this happen, so I thought I'd share my solution. I am a professional poker player and play four different tournaments at the same time on my second monitor. When I open the tournaments, they open on my main monitor. I wanted a quick way to move the tournament to the other monitor (easy) and anchor it to a corner of the screen.

My solution involves setting up a hotkey for CTRL-1 to CTRL-9 on the numeric keypad. Each of these hotkeys runs the following script with its number as a parameter; that is, CTRL-1 will run "moveto.vbs 1", etc. Then CTRL-0 is set as a hotkey to move the current window to the next monitor.

Now when I open a tournament, I hit CTRL-0 to move the tournament to the next screen, and then I hit CTRL-7, CTRL-9, CTRL-1, or CTRL-3 to move it to each corner. The application also has support for the other 5 numbers/spots, so CTRL-5 automatically centers the current window on the monitor it's on. I'd love to see this sort of feature natively supported in UltraMon, but this is pretty solid as it stands.

-- moveto.vbs --
Command = WScript.Arguments.Item(0) Set wnd = CreateObject("UltraMon.Window") If wnd.GetForegroundWindow() = True Then Set sys = CreateObject("UltraMon.System") 'get the monitor the window is on Set mon = sys.Monitors(wnd.Monitor - 1) ' Calculate the new left position If (Command = "7" Or Command = "4" Or Command = "1") Then wnd.left = mon.WorkLeft ElseIf (Command = "8" Or Command = "5" Or Command = "2") Then wnd.left = mon.workleft + (mon.workwidth - wnd.width) / 2 ElseIf (Command = "9" Or Command = "6" Or Command = "3") Then wnd.left = mon.workleft + (mon.workwidth - wnd.width) End If ' Calculate the new top position If (Command = "7" Or Command = "8" Or Command = "9") Then wnd.top = mon.WorkTop ElseIf (Command = "4" Or Command = "5" Or Command = "6") Then wnd.top = mon.worktop + (mon.workheight - wnd.height) / 2 ElseIf (Command = "1" Or Command = "2" Or Command = "3") Then wnd.top = mon.worktop + (mon.workheight - wnd.height) End If wnd.ApplyChanges 0 End If
-- cut here --
Christian Studer   2006-01-05 08:03
Thanks for sharing the script.

I'll consider such window positioning hotkeys for UltraMon 3.

Christian Studer - www.realtimesoft.com
Rob Perelman   2006-01-05 09:58
Awesome, thanks so much. In the meantime, it's not a bad solution. I originally wrote the script in VB and had an exe running, but I figure the VBSCript would be less overhead, especially using the UltraMon objects. Plus with UltraMon it knows which monitor it's on... with the EXE it was forced to stay on the primary monitor.
Andrew Casson   2008-02-27 04:08
Hi

I also play poker and would really appreciate it if someone would help me implement this VBSCript.

I do a little programming myself in VB.Net express. I'm aware of VBScript, but have never used it.

What I need to know is where do I put this code?

I search the net for help, but only found out how to add VBSCript to a web page.

Thanks

Andy
Christian Studer   2008-02-27 09:41
You can just copy the code into a text file, then save it with a .vbs extension.

You could then configure a 'Run application or script' hotkey via UltraMon which runs the script.

Christian Studer - www.realtimesoft.com
Forums -> UltraMon™ -> Anchoring a window to a corner...

Post Reply