workingArea

Version 1.0.0 (2.82 KB) by Paul Mennen
Returns the size and position of the area of the screen where you can place figures without obscuring the taskbar.
8 Downloads
Updated 22 May 2021

View License

Suppose you want to create a small figure window at the upper-left corner of the screen and another one at the lower-right corner. The obvious way to do this is to get the screen size using get(0,'screensize') and use that to position the figures. Using that method, one of those figures would cover part of the taskbar which would not likely be your intention. To do this properly you need to query for the location and size of the screen working area (i.e available area not occupied by the task bar). One way to do this is to use this sequence:
a = figure('WindowState','maximized'); pause(.1); get(a,'outerposition')
One problem with that method is that is hard to be sure how long a pause is required. (It doesn't work without the pause.) And even if you immediately delete or resize the figure you will still see the screen flash unnecessarily. Another problem with that method is that it will only work on Matlab version R2020a or newer. For older versions of Matlab, the same thing could be done using the JavaFrame undocumented feature, but that won't work with even older versions of Matlab or with Octave. This function solves that problem by returning the screen working area without needing to create a dummy figure window and it works across all Matlab versions (and even Octave).
Unfortunately this function has only been tested under Windows 10 and probably would need substantial modification to work under Linux or Mac OS.
Type "help workingArea" to see eight examples of using this function to create figure windows of various sizes and positions.

Cite As

Paul Mennen (2024). workingArea (https://www.mathworks.com/matlabcentral/fileexchange/92688-workingarea), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2021a
Compatible with any release
Platform Compatibility
Windows macOS Linux
Tags Add Tags

Community Treasure Hunt

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

Start Hunting!
Version Published Release Notes
1.0.0