after run some script, i got so many error dialog, how to quickly close them at one time.

 Akzeptierte Antwort

Adam Danz
Adam Danz am 29 Aug. 2023
Bearbeitet: Adam Danz am 30 Aug. 2023

1 Stimme

Error dialogs produced by errordlg or msgbox produce figures. The command below will close all existing figures.
close(findall(groot,'type','figure'))
If you want to only close all dialogs produced by errordlg,
close(findall(groot,'type','figure','tag','Msgbox_Error Dialog'))
If you want to only close all dialogs produced by msgbox,
close(findall(groot,'type','figure','tag','Msgbox_ '))

2 Kommentare

wenchao zhang
wenchao zhang am 29 Aug. 2023
i will try tomorrow,thanks.
wenchao zhang
wenchao zhang am 31 Aug. 2023
today, i tried, it works as expected.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

Image Analyst
Image Analyst am 29 Aug. 2023

0 Stimmen

Fix the code or data so that the errors never occur. Or else just call "return" instead of
uiwait(errordlg("You made a mistake!"))
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:

7 Kommentare

wenchao zhang
wenchao zhang am 29 Aug. 2023
thanks for you quiuck respond, may be you are missing understanding, i mean many error dialogues already showed on my screen, i want use one command to directly close them.
I understood you. I'm just saying that since you have error messages, you must have errors. So avoid the messages by avoiding the errors.
If you can't avoid the errors, or don't want to, then you can replace the error message with questdlg and if the user clicks a button, then exit the program entirely so that the other messages don't appear.
Alternatively you can use java robot. Adapt the code below to have it click on the location of the OK buttons on the error messages.
% Demo to use java robot to push buttons on a web page
% WARNING: Make sure that the coordinates in this file won't click on anything dangerous.
% You should verify the coordinates before running this.
clc;
import java.awt.Robot
import java.awt.event.*
mouse = Robot;
% Press a push button on the page.
% Move to pixel (330, 455) on the computer screen.
mouse.mouseMove(330, 455); % First message.
mouse.mousePress(InputEvent.BUTTON1_MASK);
mouse.mouseRelease(InputEvent.BUTTON1_MASK);
pause(1); % Give time for page to refresh.
% To perform right click (BUTTON3) and get the menu(works fine)
mouse.mouseMove(270, 505);
mouse.mousePress(InputEvent.BUTTON1_MASK);
mouse.mouseRelease(InputEvent.BUTTON1_MASK);
% Click next page button.
pause(2); % Give time for page to refresh.
mouse.mouseMove(940, 422); % Next page.
mouse.mousePress(InputEvent.BUTTON1_MASK);
mouse.mouseRelease(InputEvent.BUTTON1_MASK);
% Put mouse over MATLAB run button.
mouse.mouseMove(1520, 74);
fprintf('Done.\n');
wenchao zhang
wenchao zhang am 29 Aug. 2023
because of limited stateflow licenses,i use script to load the simulink model with stateflow,and hope it can got the license,so if the stateflow license not get at this time,error dialog will appears, it is ok,i can accept, but many times tried and failed to get the license,error dialog will added one by one,i dont worry about the error dialog, i just want close all the error dialog use one command, close all the error dialog one by one use mouse is not efficense
Image Analyst
Image Analyst am 29 Aug. 2023
Yep, java robot will do that for you as long as you can put it into a script that can be run after all the error messages have finished appearing.
wenchao zhang
wenchao zhang am 29 Aug. 2023
when i stop the script, i want clean all the error dialog that appeared on my screen, this error is not throwed by the script,it is raised by the reason when load the model(with stateflow) with abcense of stateflow license, sorry, hope it clear more.
Image Analyst
Image Analyst am 29 Aug. 2023
Yes, I know. And I also know that obviously you never tried my solution. However I think Adam may have a better answer below. Of course both of our solutions mean running code, either as a script (mine) or in the command window (Adam's).
wenchao zhang
wenchao zhang am 29 Aug. 2023
yes, as adam shows, i just want write these command to clear this error dialog, any way thanks for your answers.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Aerospace Applications finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by