Lisp HUG Maillist Archive

create-instance/create-object

Unable to parse email body. Email id is 6834

AW: create-instance/create-object


> -----Ursprüngliche Nachricht-----
> Von: owner-lisp-hug@lispworks.com 
> [mailto:owner-lisp-hug@lispworks.com] Im Auftrag von Brian Connoy
> Gesendet: Montag, 23. Juli 2007 20:33
> An: lisp-hug@lispworks.com
> Betreff: create-instance/create-object
> ...
> Each variation of (com:create-instance) or 
> (com:create-object) I could muster, with or without the type 
> library referenced, always yields for me a second instance of 
> AutoCAD, in addition to that already running. I no longer 
> recall the variations tried, so my simple question will be:  
> ...

Hi Brian,

I had a similar problem when controlling MS Internet Explorer (IE). I found the shell object helpful although it might not be a
solution for you (I am not sure). Using com:create-instance always made a new instance of IE. With the shell object I find a running
instance and connect to it. This is the fragment from my code:

(defun find-ie ()
  (let* ((shell (com:create-instance "Shell.Application" :riid 'com:i-dispatch))
         (windows (com:invoke-dispatch-method shell "Windows"))
         (count (com:invoke-dispatch-get-property windows "Count"))
         (ie (loop :for i :from 0 :to (1- count)
                   :for obj = (com:invoke-dispatch-method windows "Item" i)
                   :do
                   (unless (eq obj :nothing) (return obj)))))
    (if ie
        (values ie :living)
      (progn
        (setf ie (com:create-instance "InternetExplorer.Application" :riid 'com:i-dispatch))
        (com:invoke-dispatch-put-property ie "Visible" "true")
        (values ie :fresh)))))

(defun nav-ie (url)
  (multiple-value-bind (ie state) (find-ie)
    (com:invoke-dispatch-method ie "Navigate" url (unless (eq state :fresh) #x800))
    ;; make ie top-most
    (let ((hwnd (com:invoke-dispatch-get-property ie "HWND")))
      (win32:set-window-pos hwnd 0 0 0 0 0 3))))

I'm not sure if shell can give you a reference to AutoCAD.

Andreas

(P.S. Maybe my mailer scrambles line breaks.)


AW: create-instance/create-object

Unable to parse email body. Email id is 6843

Re: create-instance/create-object

Unable to parse email body. Email id is 6845

Re: create-instance/create-object

Unable to parse email body. Email id is 6850

Updated at: 2020-12-10 08:45 UTC