Hi all,
i use two monitors for my work - laptop and an external - and i'd really love to specify that when a program is executed, the run window is on the external monitor rather than the laptop. Is there a simple way to do this?
(i posted this here as i figured it related to user interface - apologies if it should be elsewhere!)
Specifying monitor?
Re: Specifying monitor?
Hi 5against4,
It probably depends on how you have configured the two monitors, but you should be able to use SYS "MoveWindow" to achieve what you want. Here's a brief demo that works on my two screen system (continuous desktop, with the "main" monitor being the right one). Here I let the default window open for 1 second, then move it to near the top left of the main screen, wait a second, then use a negative x coordinate to put it on the left hand screen.
Note that MoveWindow will/can also change the size of the window, so you might want to find out what size it is first, perhaps by using GetWindowRect.
If you are just doing it for your own convenience on your own setup, messing around to find the right parameters is probably acceptable: if you wanted to do something in a program for general use you'd probably need to start out by finding out the parameters of the screen(s) available. I'd have to swot that up....
Best wishes,
D
It probably depends on how you have configured the two monitors, but you should be able to use SYS "MoveWindow" to achieve what you want. Here's a brief demo that works on my two screen system (continuous desktop, with the "main" monitor being the right one). Here I let the default window open for 1 second, then move it to near the top left of the main screen, wait a second, then use a negative x coordinate to put it on the left hand screen.
Note that MoveWindow will/can also change the size of the window, so you might want to find out what size it is first, perhaps by using GetWindowRect.
If you are just doing it for your own convenience on your own setup, messing around to find the right parameters is probably acceptable: if you wanted to do something in a program for general use you'd probably need to start out by finding out the parameters of the screen(s) available. I'd have to swot that up....
Best wishes,
D
Code: Select all
WAIT 100
SYS "MoveWindow",@hwnd%,100,100,800,600,TRUE TO res%
IF res%=0 PRINT"Failed to move"
WAIT 100
SYS "MoveWindow",@hwnd%,-1000,100,800,600,TRUE TO res%
IF res%=0 PRINT"Failed to move"
WAIT 100
- 5against4
- Posts: 21
- Joined: Tue 03 Apr 2018, 11:57
- Location: The Cotswolds
Re: Specifying monitor?
Hi DDRM,
Thanks for reminding me about the existence of MoveWindow! Stupidly i'd completely forgotten, which is all the more embarrassing as i use the ShowWindow function all the time to maximise the window
So after a quick bit of experimenting, this works perfectly:
This is just for my own convenience, not for general use, so this simple solution is really ideal. Thanks!! 
Thanks for reminding me about the existence of MoveWindow! Stupidly i'd completely forgotten, which is all the more embarrassing as i use the ShowWindow function all the time to maximise the window

So after a quick bit of experimenting, this works perfectly:
Code: Select all
SYS "MoveWindow",@hwnd%,0,-1000,1920,1080,1 : REM Shifts to second monitor
SYS "ShowWindow", @hwnd%, 3 : REM Maximises window

-
- Posts: 327
- Joined: Wed 04 Apr 2018, 06:36
Re: Specifying monitor?
This is something I do with my Display program. Where it falls down is that you have to set the position of the window according to the position of the monitor as set by your Display Settings. Thus if you have your monitors arranged 1-2 you will have to set the window to +screenx% to have it appear on monitor 2, but if your monitors are arranged 2-1 you will have to set the window to -screenx% (where screenx% holds the width of the screen).
Things get even more complicated when you have three displays (as I do), as you have to make sure that they are set up 1-2-3 and not 1-3-2 or 3-2-1 or any other possible combination!
Oh, and you have to be sure that the monitors are on the same level in the Display Settings!
Things get even more complicated when you have three displays (as I do), as you have to make sure that they are set up 1-2-3 and not 1-3-2 or 3-2-1 or any other possible combination!
Oh, and you have to be sure that the monitors are on the same level in the Display Settings!