Wait for app to close before continuing script execution

조회 수: 18 (최근 30일)
Nicola Dall'Osto
Nicola Dall'Osto 2024년 4월 16일
댓글: Taylor 2024년 4월 17일
I have a matlab script that opens Medical Image Labeler app of Image Processing Toolbox and uploads some images in it. I need the script to wait until the user segments the images and once the app is closed the script continue its execution.
The only solution that I've tried to implement was to add the following line of code.
uiwait(msgbox('This message will pause execution until you click OK'));
This command shows a message box and pauses the script execution until the user presses "OK".
But this is not an ideal solution for me. It will be much better if the user has to simply close the app, becuase the message box appears in front of the app's window and not in the background.
  댓글 수: 1
Nicola Dall'Osto
Nicola Dall'Osto 2024년 4월 17일
Is there a way to close an app (not made with App Designer) with a command?

댓글을 달려면 로그인하십시오.

답변 (1개)

Taylor
Taylor 2024년 4월 16일
To my knowledge there is currently no way to check the window status of shipped apps like Medical Image Labeler.
A workaround could be to use a while loop after you call Medical Image Labeler that looks for the MAT file you will save in the Medical Image Labeler app. Here's an example of this logic:
medicalImageLabeler
while ~exist("groundTruthMed.mat", "file")
disp("Waiting for file")
pause(2)
end
disp("Ground Truth file found!")
  댓글 수: 4
Nicola Dall'Osto
Nicola Dall'Osto 2024년 4월 16일
You are right, but in this way I can't use the autosave feature, which is essential for my work. Moreover, since every user can export the .mat file with different name, I can't know what name to search for the file with.
Taylor
Taylor 2024년 4월 17일
Ah ok I see. Short of using system to terminate a process based on PID, I'm not sure if I have any alternative methods beyond what you are already doing. Frankly, I don't know if that would even be superior to what you are doing currently.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Matrix Indexing에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by