how to close error dialog
이전 댓글 표시
after run some script, i got so many error dialog, how to quickly close them at one time.
채택된 답변
추가 답변 (1개)
Image Analyst
2023년 8월 29일
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
wenchao zhang
2023년 8월 29일
Image Analyst
2023년 8월 29일
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
2023년 8월 29일
Image Analyst
2023년 8월 29일
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
2023년 8월 29일
Image Analyst
2023년 8월 29일
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
2023년 8월 29일
카테고리
도움말 센터 및 File Exchange에서 Aerospace Applications에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!