File Exchange

image thumbnail

Get screen size (dynamic)

version 1.0.0.1 (3.57 KB) by Bill York
Same as get( 0, 'ScreenSize' ), but dynamic

5 Downloads

Updated 01 Sep 2016

View License

GETSCREENSIZE Same as get( 0, 'ScreenSize' ), but dynamic

SZ = GETSCREENSIZE returns a 1x4 vector of doubles giving the size of the display in pixels, in the same way as get( 0, 'ScreenSize' ), except it reads the current settings rather than reading a static copy made at MATLAB® startup time.
From "doc rootobject_props":

"Note that the ScreenSize property is static. Its values are read only at MATLAB startup and not updated if system display settings change."

Some applications place windows based on on the display resolution, and the resolution can change - mine does when I disconnect my laptop from my external monitor.

Cite As

Bill York (2020). Get screen size (dynamic) (https://www.mathworks.com/matlabcentral/fileexchange/10957-get-screen-size-dynamic), MATLAB Central File Exchange. Retrieved .

Comments and Ratings (12)

Thx, but this does not behave as get(0,'MonitorPositions') in the event of multiple monitors.
It returns only one monitor size, whereas get(0,'MonitorPositions') returns a matrix with all positions & sizes.

James Ang

Thank you!

Good tool!
If you need to use it on 64bit, compile a new mex file with the command:
mex getScreenSize.c

Wen

I can't seem to find how to use this. The function body is empty.

Wen

Holger

One can also use
java.awt.Toolkit.getDefaultToolkit().getScreenSize()

very good tool . need to use it on 64 bit windows , any help ?!

Thank you very much. What a PIA without this.

Lucas

Good job. Thanks for this !

Lucas

Markus Buehren

Thanks for putting that little but smart tool here!

I just would call the function GETSCREENSIZEINPIXELS to avoid any errors due to the current root units setting.

Any idea how to implement such thing under Linux?

Tim Farajian

Useful tool Russel. I will be using it.

Updates

1.0.0.1

Updated license

MATLAB Release Compatibility
Created with R2006a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Acknowledgements

Inspired: Get Monitor Dimensions

getScreenSize/