Detect from matlab whether other programs are not responding [SOLVED]

I'd like to share something I couldn't find a straightforward answer to by googling.
I use a program outside matlab to make some calculations. I write the code for the program in matlab, load it outside matlab, and then interact with the program's GUI for it to run. finally I import the calculated outputs. Loading the files in the program commonly puts it in "not responding" mode for few seconds and I'd like to interact with the GUI when it comes back to life.
To detect wether it's not responding I use:
[~,result] = system('tasklist /fi "status eq not responding" /fi "Imagename eq phreeqci.exe" /nh');
where "phreeqci.exe" is my program (as presented in Tasklist or Task Manager). "result" will give a line with details about the program if it is in fact non-responsive and the warning:
INFO: No tasks are running which match the specified criteria.
if it is responsive.
waiting for it to respond looks like this:
status=0;
while status==0
[~,result] = system('tasklist /fi "status eq not responding" /fi "Imagename eq phreeqci.exe" /nh');
status=strcmp(result,[['INFO: No tasks are running which match the specified criteria.' char(10) '']]);
end
fprintf('Responsive!\n')
I was not familiar with using the command line and this link helped me: https://technet.microsoft.com/en-us/library/bb491010.aspx
Hope this would help someone out there.

답변 (0개)

카테고리

도움말 센터File Exchange에서 Financial Toolbox에 대해 자세히 알아보기

질문:

2016년 12월 22일

편집:

2016년 12월 22일

Community Treasure Hunt

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

Start Hunting!

Translated by