check if an external application is running or not from matlab

19 次查看(过去 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.

采纳的回答

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 CenterFile Exchange 中查找有关 Environment and Settings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by