Jump to content

Recommended Posts

Posted

Is it possible to close a windows application via lisp? ie mspaint, excel or word. Thanks.

Posted

Did you look up some of the examples for opening say excel then closing would be the same. have a look at say GETEXCEL.LSP

Posted

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.

Posted

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

Posted

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)

Posted

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)

Posted
Lee what about (graphscr) option

 

I can't test, but I'm not sure whether (graphscr) works when the Text Window is on a second monitor.

Posted

I confirm that the GRAPHSCR call will close the text window only when is on the same screen as main, graphical, one.

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