check if an external application is running or not from matlab

9 ビュー (過去 30 日間)
Krishna
Krishna 2011 年 10 月 3 日
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.

採用された回答

Jason Ross
Jason Ross 2011 年 10 月 3 日
  3 件のコメント
Matthew
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
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 ExchangeCall Java from MATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by