TheSwamp

Code Red => .NET => Topic started by: simor on October 17, 2008, 08:04:22 AM

Title: [NSIS] How to check if AutoCAD is running and locking my files?
Post by: simor on October 17, 2008, 08:04:22 AM
I'm doing an NSIS installer and want to check if AutoCAD (2008) is running. I was trying to use FindWindow but it seems that AutoCAD's window has a variable class name..

Code: [Select]
Afx:00400000:8:00010011:00000000:xxxxxxxx
The last part is changing at every startup so I can't use it. I tried googling it, found this:
http://mail.python.org/pipermail/python-win32/2007-February/005559.html
Unfortunately I think he was guessing because I couldn't confirm his theory with the parent class name.

Trying to find acad.exe in running processes is a bit messy under NSIS, haven't tried it yet and I'm not sure that I can find the window caption by process. Will be investigating this...

I don't want to go through all open windows checking their class name and caption nor trying to rename acad.exe to find if its locked or not :ugly:

Any ideas?
Title: Re: How to check if AutoCAD is running?
Post by: TonyT on October 18, 2008, 08:33:49 AM
Any ideas?

   COM ?
Title: Re: How to check if AutoCAD is running?
Post by: FengK on October 18, 2008, 06:33:49 PM
Google for AutoItX, a DLL version of AutoIt v3 that provides a subset of the features of AutoIt via an ActiveX/COM and DLL interface. It has a "ProcessExists" method.
http://www.autoitscript.com/autoit3/docs/functions/ProcessExists.htm
Title: Re: How to check if AutoCAD is running?
Post by: simor on October 19, 2008, 09:52:56 AM
   COM ?

I'm not sure how to do that in NSIS.. if it's even possible, I didn't find any mention of COMs in the manual :| but it would be some solution...

Google for AutoItX, a DLL version of AutoIt v3 that provides a subset of the features of AutoIt via an ActiveX/COM and DLL interface. It has a "ProcessExists" method.
http://www.autoitscript.com/autoit3/docs/functions/ProcessExists.htm

I mentioned search for the process (eg. using this (http://nsis.sourceforge.net/Processes_plug-in)) but if I find acad.exe I won't know if it's AutoCAD 2008 or a different one... right (?)


Title: Re: How to check if AutoCAD is running?
Post by: simor on October 20, 2008, 05:27:18 AM
I ended up with two solutions, I found a script to look for variable window class names (http://nsis.sourceforge.net/Enhanced_FindWindow_for_variable_window_class_names) which requires one simple change and can look for variable window captions.. but the second solution is way better: LockedList plug-in (http://nsis.sourceforge.net/LockedList_plug-in). First you feed it with names of files and then it checks if they are in use by any running application and lists those apps in a listbox. Which is really what I was after..
Cool or what..  ^-^