Ahankhah Posted April 26, 2011 Posted April 26, 2011 Hello CADTutor members, I found a code by Lee Mac to open a folder by AutoLISP here. The code follows: (defun MT-Explore (Directory / Shell result) (setq Shell (vla-getInterfaceObject (vlax-get-acad-object) "Shell.Application" ) ) (setq result (vl-catch-all-apply 'vlax-invoke (list Shell 'Explore Directory)) ) (vlax-release-object Shell) (not (vl-catch-all-error-p result)) ) Should anyone know how to close the opened folder? Quote
Lee Mac Posted April 26, 2011 Posted April 26, 2011 The only thing that comes to mind is a Termination script, but such methods are dangerous if you terminate the wrong process - so be careful. (defun LM:Terminate ( process / wmi server query name ) (vl-catch-all-apply (function (lambda ( / name ) (setq process (strcase process) wmi (vlax-create-object "WbemScripting.SWbemLocator") server (vlax-invoke wmi 'connectserver nil nil nil nil nil nil nil nil) query (vlax-invoke server 'execquery "Select * from Win32_Process") ) (vlax-for item query (if (and (setq name (vlax-get item 'commandline)) (vl-string-search process (strcase name)) ) (vlax-invoke item 'terminate) ) ) ) ) ) (foreach object (list wmi server query) (if (and object (not (vlax-object-released-p object))) (vlax-release-object object) ) ) ) Call with name of process to terminate, e.g.: (LM:Terminate "Excel.exe") Quote
Organic Posted April 26, 2011 Posted April 26, 2011 How would that work though, i.e. a folder does not have its own process as far as I am aware and comes under the explorer.exe process. Terminating that will shutdown the taskbar and all other folder functionality, not just one folder. Quote
Lee Mac Posted April 26, 2011 Posted April 26, 2011 Good point Dink - I'm fresh out of ideas on this one then Quote
alanjt Posted April 26, 2011 Posted April 26, 2011 How hard is it to click on the little "X" at the top right of the window or type ALT+F4 or CTRL+W? Quote
Lee Mac Posted April 26, 2011 Posted April 26, 2011 How hard is it to click on the little "X" at the top right of the window or type ALT+F4 or CTRL+W? True, but I'm positive that same argument could be applied to many of the tasks for which we write code - I'm sure you'll agree that it is often interesting to see if something can be achieved programmatically. In this case however, I doubt a programmatic method will be found. Lee Quote
alanjt Posted April 26, 2011 Posted April 26, 2011 True, but I'm positive that same argument could be applied to many of the tasks for which we write code - I'm sure you'll agree that it is often interesting to see if something can be achieved programmatically. In this case however, I doubt a programmatic method will be found. Lee Sort-of agree. In this situation, I don't see how it's possible. Even if you could isolate active windows explorer windows, how would you isolate the specific one, if more than one is open. 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.