Jump to content

Close windows application


ketongin

Recommended Posts

If the application that you want to close was open via your AutoLISP code, then is easy to close it since you know its identifiers.

Other you must locate the running process - this is done usually using the content of its caption (label on title bar). However this is quite difficult and not always reliable. It also cannot be done with plain AutoLISP.

Link to comment
Share on other sites

The process that I want to kill is "Autocad Text Window" I've search everywhere but couldn't find a solution. Since F2 doesn't work if the window pop-up on the second monitor.

 

My goal is

F2 = open acad windows

2 = Close acad windows

Link to comment
Share on other sites

Try this:

(defun c:CTW ( / wsh )
   (if (setq wsh (vlax-create-object "wscript.shell"))
       (progn
           (textscr)
           (vl-catch-all-apply
              '(lambda ( )
                   (vlax-invoke wsh 'appactivate "AutoCAD Text Window")
                   (vlax-invoke wsh 'sendkeys "% H")
               )
           )
           (vlax-release-object wsh)
       )
   )
   (princ)
)
(vl-load-com) (princ)

Link to comment
Share on other sites

many thanks Lee. Works great.

 

Try this:

(defun c:CTW ( / wsh )
   (if (setq wsh (vlax-create-object "wscript.shell"))
       (progn
           (textscr)
           (vl-catch-all-apply
              '(lambda ( )
                   (vlax-invoke wsh 'appactivate "AutoCAD Text Window")
                   (vlax-invoke wsh 'sendkeys "% H")
               )
           )
           (vlax-release-object wsh)
       )
   )
   (princ)
)
(vl-load-com) (princ)

Link to comment
Share on other sites

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