How to get the actual MonitorPosition, particularly with Windows scaling and changin monitor configurations?

20 Ansichten (letzte 30 Tage)
Hi,
we are usually working using laptops and external 1 or 2 monitors, such we have 1-3 monitors. Sometimes (e.g. when removing the laptop from the docking station), the number of monitors changes during a running MATLAB session. We need to position a number of figures and need the monitor positions at the current time for this. However,
get(0, 'MonitorPositions' )
seems to always return the monitor configuration at the time MATLAB was started.
We already tried to implement a workaround using Java (java.awt.GraphicsEnvironment.getLocalGraphicsEnvironment ...) but we don't get the correct positions via this way when Windows Scaling (125% or 150%) ist used.
Is there any way to always get the correct monitor position, even with windos scaling and changing monitor positions during a running MATLAB session?
  3 Kommentare
Jan
Jan am 5 Okt. 2017
Bearbeitet: Jan am 5 Okt. 2017
How is the "correct" position defined, when Windows scales the output?
Perhaps https://www.mathworks.com/matlabcentral/fileexchange/31437-windowapi is useful under Windows. But I do not have much experiences with scaling.
Kanthaswamy Ganapathy
Kanthaswamy Ganapathy am 29 Dez. 2022
Hi,
Please find a fix as below. It was tried and found working in our setup with secondary monitor
if we require units in pixels, use
set(0,'units','pixels');
get(0,'MonitorPositions');
Regards,
Kanthaswamy

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by