Small Fish Posted August 16, 2009 Posted August 16, 2009 How can I check if an application is already open? I have in my case I have an executable file, and I would like a 'princ' or 'alert' message saying file open - if this is the case. many thanks Quote
CADMASTER1128 Posted August 16, 2009 Posted August 16, 2009 Are you talking about a LISP program? Are you wanting to see if it working? Quote
Small Fish Posted August 16, 2009 Author Posted August 16, 2009 No its an executable file - although to launch I am using Autolisp. Below is what I have so far. Now I want to add some lines in to show a message if the user tries to open it when it's already open The executable is called CloseDialog.exe (defun C:CloseDialog (/) (startapp "CloseDialog") (alert(strcat "\nDialogue box suppression is now active." );strcat );alert (princ) );defun Quote
Small Fish Posted August 16, 2009 Author Posted August 16, 2009 No I use the macro in the CUI to load the above lisp and 'startapp' to load the exe Quote
Lee Mac Posted August 16, 2009 Posted August 16, 2009 Hi SmallFish, I think Steve may be a bit off the mark with this one - lets see if I can strike a bit closer :wink: My first thought was vl-vlx-loaded-p, but of course, this only checks for vlx applications. So, thinking laterally, why not just use a global var, and set it to the return of the startapp? i.e. (setq *var (startapp "CloseDialog")) Then use a conditional to check for the *var? Lee Quote
CADMASTER1128 Posted August 16, 2009 Posted August 16, 2009 Hi SmallFish, I think Steve may be a bit off the mark with this one - lets see if I can strike a bit closer :wink: My first thought was vl-vlx-loaded-p, but of course, this only checks for vlx applications. So, thinking laterally, why not just use a global var, and set it to the return of the startapp? i.e. (setq *var (startapp "CloseDialog")) Then use a conditional to check for the *var? Lee I will let you take this one ever Lee, Thanks Quote
Small Fish Posted August 17, 2009 Author Posted August 17, 2009 Thanks Lee Mac I like your idea unfortunately it does not work. (setq *var (startapp "CloseDialog")) Will return the number 33. I am not sure what 33 means but that's not important for what I want. If I test *var for a value of 33 then it means the app is loaded if True However if I go into another dwg it and load the app it will return a value of nil even though its open. Perhaps it can not be done? My guess is that the exe file is an arx (c++) file. This exe file will stay open even Acad is closed. Quote
fuccaro Posted August 17, 2009 Posted August 17, 2009 Well, I used to use something like: (if (not (member "geomcal.arx" (arx))) (arxload "geomcal")) Does that help you? Quote
Lee Mac Posted August 17, 2009 Posted August 17, 2009 Well, I used to use something like:(if (not (member "geomcal.arx" (arx))) (arxload "geomcal")) Does that help you? Spot on Fuccaro, nice one. Quote
Patrick_35 Posted August 17, 2009 Posted August 17, 2009 Hi If this is to check if a file is in use, you should (open "My_File" "a") and if I get nil is that the file is used. Otherwise, another method by looking in the process (defun appli(/ apps item lst meth1 meth2 WMI) (setq WMI (vlax-create-object "WbemScripting.SWbemLocator") meth1 (vlax-invoke WMI 'ConnectServer nil nil nil nil nil nil nil nil) meth2 (vlax-invoke meth1 'ExecQuery "Select * from Win32_Process") ) (vlax-for item meth2 (setq lst (cons (vlax-get item 'CommandLine) lst)) ) (foreach item (list WMI meth1 meth2) (vlax-release-object item) ) (vl-remove nil lst) ) @+ Quote
Small Fish Posted August 17, 2009 Author Posted August 17, 2009 Thanks guys - I have also found something that will work - it's the doslib function: dos_processes Returns a list of processes, or tasks, running on the system. (dos_processes [T]) Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.