Mace
Mace

Reputation: 1269

Making the MATLAB editor or command window grab focus programmatically

When Matlab is processing code including the plot() command, Matlab will steal window focus, when plot() is processed. While many seem to find this behavior annoying, I find it useful as an alert telling me when the plot has been processed, and I can do something else while Matlab is running.

I would, however, like to have Matlab stealing window focus whenever calculations are done (Matlab being idle), and not just when I include the plot() or figure() command.

I have found a post about disabling the window stealing behavior of plot() and figure() (Inhibit Matlab Window Focus Stealing), but not on adding window stealing behavior when calculations are done. Can it be done?

Upvotes: 3

Views: 1579

Answers (1)

Luis Mendo
Luis Mendo

Reputation: 112669

To make Matlab command window get focus, you can add commandwindow after the calculations. From the documentation,

commandwindow opens the MATLAB® Command Window when it is closed, and selects the Command Window when it is open.

To make an existing figure get focus, you can add figure(h), where h is the figure handle. From the documentation,

figure(h) does one of the following [...]

If h is the handle or the Number property value of an existing figure, then figure(h) makes that existing figure the current figure, makes it visible, and moves it on top of all other figures on the screen. The current figure is the target for graphics output.

Upvotes: 3

Related Questions