Jump to content

Recommended Posts

Posted

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

Posted

Are you talking about a LISP program? Are you wanting to see if it working?

Posted

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

Posted

So you load via "APPLOAD" correct?

Posted

No I use the macro in the CUI to load the above lisp and 'startapp' to load the exe

Posted

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

Posted
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 :)

Posted

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.

Posted

Well, I used to use something like:

(if (not (member "geomcal.arx" (arx))) (arxload "geomcal"))

Does that help you?

Posted
Well, I used to use something like:

(if (not (member "geomcal.arx" (arx))) (arxload "geomcal"))

Does that help you?

 

Spot on Fuccaro, nice one. :)

Posted

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)
)

@+

Posted

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])

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...