check if an external application is running or not from matlab
조회 수: 9 (최근 30일)
이전 댓글 표시
I have an application opened from Matlab. I would like to check if the instance of the application is running or not from Matlab. If the application instance is running I would like to bring the window into focus and perform certain actions. Considering the external application as Notepad please let me know if this can be done. I tried using wscript shell COM component and the appactivate method in it, but no use. I am sure that this can be done using Java commands from Matlab, but not very familiar with Java though.
Thanks in advance. Krishna.
댓글 수: 0
채택된 답변
Jason Ross
2011년 10월 3일
댓글 수: 3
Matthew
2013년 5월 6일
Do you have a solution for this on MAC OS X? Running apps are indicated in the 'force quit' screen and in the activity monitor, but I need Matlab (2012a) to know if an app is running or not.
Jason Ross
2013년 5월 6일
On UNIX systems this is actually quite easier since the shell provides a lot of utilities that work really well together. For example,
pgrep matlab | wc -l
or
ps -ef | grep matlab | wc -l
will give you a count of the number of MATLAB processes running. Change what you are grepping for if you need to. On Mac, the options of ps may be a little different (it might be ps -A), but you can tweak it as you need to.
What's happening here is that the "pgrep matlab" or "ps -ef | grep matlab" parts give a list of processes that have "matlab" in them, and then the "wc -l" (wc = word count) counts the number of lines.
There are also shell commands that can easily give you your process ID, and you can tell from the process table which processes started what. You can get this same information on Windows, but it takes more work or a utility like the PS Tools to get at it.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Java from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!