Multi Monitor - MoveWindow
Moderators: JRL, Dorian (MJT support)
-
- Pro Scripter
- Posts: 110
- Joined: Thu Apr 08, 2010 6:11 am
- Location: Hørsholm, Denmark
- Contact:
Multi Monitor - MoveWindow
Hi,
In a multi monitor setup - is it possibe to move a window to monitor 2 or 3
and maximize it ?
And how do I detect how many monitors are present ?
In a multi monitor setup - is it possibe to move a window to monitor 2 or 3
and maximize it ?
And how do I detect how many monitors are present ?
Best Regards
Steen Jakobsen
DM Software A/S
Steen Jakobsen
DM Software A/S
http://www.mjtnet.com/forum/viewtopic.php?t=4960
The above will get you number and size. I have no good idea how to move your window to a specific monitor. Perhaps moving it to a guestimated location then maximizing will work???
The above will get you number and size. I have no good idea how to move your window to a specific monitor. Perhaps moving it to a guestimated location then maximizing will work???
-
- Pro Scripter
- Posts: 110
- Joined: Thu Apr 08, 2010 6:11 am
- Location: Hørsholm, Denmark
- Contact:
Hi JRL,
Thanks a lot
this is the code for detecting how many monitors - and it works fine.
Now I just need to find a way to move a window from monitor 1 to monitor 2 and maximize it ..
Any body have a clue ?
Thanks a lot

this is the code for detecting how many monitors - and it works fine.
Code: Select all
// Number of monitors
Let>SM_CMONITORS=80
// Virtual Width
Let>SM_CXVIRTUALSCREEN=78
// Virtual Height
Let>SM_CYVIRTUALSCREEN=79
LibFunc>user32,GetSystemMetrics,mcnt,SM_CMONITORS
LibFunc>user32,GetSystemMetrics,vsw,SM_CXVIRTUALSCREEN
LibFunc>user32,GetSystemMetrics,vsh,SM_CYVIRTUALSCREEN
MessageModal>You have %mcnt% monitors%CRLF%Virtual Screen Size: %vsw%x%vsh% px
Now I just need to find a way to move a window from monitor 1 to monitor 2 and maximize it ..
Any body have a clue ?
Best Regards
Steen Jakobsen
DM Software A/S
Steen Jakobsen
DM Software A/S
You didn't say whether or not you tried estimating the screen positions. I don't have multiple monitors to try this on so this is just a guess.
Seems like after running the GetSystemMetrics API you should be able to divide the screen width by the number of monitors and then move the window to an approximate position based on that math. Then use WindowAction> to maximize the window. I would expect the window to maximize onto whichever screen the upper left corner of the window is sitting in.
WindowAction>1,window_title will maximize a window.
Seems like after running the GetSystemMetrics API you should be able to divide the screen width by the number of monitors and then move the window to an approximate position based on that math. Then use WindowAction> to maximize the window. I would expect the window to maximize onto whichever screen the upper left corner of the window is sitting in.
WindowAction>1,window_title will maximize a window.
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
JRL: That relies on knowing where each monitor is in relation to the other. Are they all in a row, one on top of another and a third to the right, and which one is the primary?
What you need is a function to retrieve the virtual desktop coordinates and size of a given monitor. I expect an API function to do that exists, but I don't know off the top of my head what it is, or whether it would be something that Macro Scheduler could use natively.
What you need is a function to retrieve the virtual desktop coordinates and size of a given monitor. I expect an API function to do that exists, but I don't know off the top of my head what it is, or whether it would be something that Macro Scheduler could use natively.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
- Marcus Tettmar
- Site Admin
- Posts: 7395
- Joined: Thu Sep 19, 2002 3:00 pm
- Location: Dorset, UK
- Contact:
Of course It can. Windows does. The size, layout and position of each monitor is defined in Display Properties. There must therefore be an API to retrieve that info. I'm on a blackberry right now so can't easily find out at this time.
Marcus Tettmar
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
http://mjtnet.com/blog/ | http://twitter.com/marcustettmar
Did you know we are now offering affordable monthly subscriptions for Macro Scheduler Standard?
-
- Pro Scripter
- Posts: 110
- Joined: Thu Apr 08, 2010 6:11 am
- Location: Hørsholm, Denmark
- Contact:
-
- Pro Scripter
- Posts: 110
- Joined: Thu Apr 08, 2010 6:11 am
- Location: Hørsholm, Denmark
- Contact:
Hi,
I have it working just file
Here is my simple code
I have it working just file

Here is my simple code
SRT>MoveToSecondMonitor
// Number of monitors
Let>SM_CMONITORS=80
// Virtual Width
Let>SM_CXVIRTUALSCREEN=78
// Virtual Height
Let>SM_CYVIRTUALSCREEN=79
LibFunc>user32,GetSystemMetrics,mcnt,SM_CMONITORS
LibFunc>user32,GetSystemMetrics,vsw,SM_CXVIRTUALSCREEN
LibFunc>user32,GetSystemMetrics,vsh,SM_CYVIRTUALSCREEN
If>%mcnt%>1 Then
let>%NewX%={(%vsw%/2) + 1}
WindowAction>0,DM.scp*
MoveWindow>DM.scp*,%newX%,1
WindowAction>1,DM.scp*
EndIf
//MessageModal>You have %mcnt% monitors%CRLF%Virtual Screen Size: %vsw%x%vsh% px
END>MoveToSecondMonitor
Best Regards
Steen Jakobsen
DM Software A/S
Steen Jakobsen
DM Software A/S