PDA

View Full Version : How do I determine if a program is running



ccowgill
2009-10-30, 04:19 PM
Is there a way to use lisp to determine if a program is running on my machine. For example, can I use lisp to determine if Microsoft Word is currently open on my machine (as a general question)? Or to be more specific, can I use Lisp to determine if Eagle Point is running while AutoCAD is open?

rkmcswain
2009-10-30, 05:11 PM
The (dos_processes) function in DOSLIB returns a list of all running processes.
http://en.wiki.mcneel.com/default.aspx/McNeel/DOSlib.html

If you are wanting to do this own your own using API calls, etc., then I'll be watching this thread also to see how...

ccowgill
2009-10-30, 05:23 PM
The (dos_processes) function in DOSLIB returns a list of all running processes.
http://en.wiki.mcneel.com/default.aspx/McNeel/DOSlib.html

If you are wanting to do this own your own using API calls, etc., then I'll be watching this thread also to see how...



(setq programlist (dos_processes))
(foreach n programlist
(if (wcmatch n "egpt.exe")
(setq flag 1)
)
)


then if flag is = 1 I know that eaglepoint is running. It will take some more testing to see if it really gives me what I want.

alanjt
2009-10-30, 05:40 PM
This might be a little less legwork:

(setq flag (vl-position "egpt.exe" (dos_processes)))

If it exists, it will give a number, nil if not. You could also use member, but vl-position is a little faster.