[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Apple events from MCL to the finder



In a previous message I asked for help with the Apple Events from MCL to the 
Finder to do simple things such as empty the trash and show the clipboard.
Thanks for the help from the net, the code for these two simple apple
avents works.

Now to make things a little bit complicated, I would like to send an 
OpenSelection apple event to start Gofer from the utilities folder on my
disk named MSRC.

Accoreding to the Registry, I needed an alias for the folder and a list of 
aliases for the selection.

Here is code I worte, that I feel very close to working, but not quite.
Any suggestions will be very much appreciated.
Thanks,

Mamdouh H. Ibrahim        - Electronic Data Systems
                            Artificial Intelligence Services
                            5555 New King Street
                            P.O. Box 7019
                            Troy, MI 48007-7019
                            (313) 696-7129
                            mhi@ais.tsd.eds.com
                            mhi@edsdrd.eds.com
                            mhi@eds.com
                            FAX:  (313) 696-2325


---------
; using appleevent-toolkit.lisp and the following high level functions

(defun put-parameter-descriptor (theEvent keyWord descriptor)
  (ae-error (#_AEPutParamDesc theEvent keyWord descriptor)))

(defun put-parameter-pointer  (theEvent keyWord codeType dataPointer dataSize)
  (ae-error (#_AEPutParamPtr theEvent keyWord codeType dataPointer dataSize)))


(defun create-an-alias ( alias path)
  (let ((namestring (mac-namestring path)))
    (ccl::with-cstrs ((cname namestring))
      (#_NewAliasMinimalFromFullPath (length namestring) cname
                        (%null-ptr) (%null-ptr) alias))) )

; Code that doesn't work  most of it copied from the appleevent-toolkit.lisp
(with-aedescs (myevent target reply alias-list)
  (choose-appleevent-target target )
  (create-appleevent myevent :|FNDR| "sope" target )
;;create an alias for the folder and insert it as the direct parameter
  (rlet  ((alias :aliashandle))
          (ccl::create-an-alias alias "MSRC:utilities:")
          (unwind-protect
            (with-dereferenced-handles ((aliasptr (%get-ptr alias)))
            (put-parameter-pointer  myevent "aedp" #$typeAlias aliasptr
                                    (rref aliasptr aliasrecord.aliassize))))
;;create a list of the selection to open and insert it as the second param
  (create-alias-list alias-list   '( "MSRC:utilities:Gofer"))
  (put-parameter-descriptor myevent "aesk" alias-list)
;;send the event
  (send-appleevent myevent reply :reply-mode :wait-reply)) )


THe above gives me the following error message on the Listener

> Error: Data in an AppleEvent could not be read. (-1702)
> While executing: SEND-APPLEEVENT
> Type Command-. to abort.


However, if I change the keyword "aedp", which is the value I found in the 
Registry for the DirectParameter, and replace it with the constant
#$keyDirectObject, the code looks as follows 


       (put-parameter-pointer  myevent #$keyDirectObject #$typeAlias aliasptr)

Then I get the attention of the Finder as if it trying to do what I want
 but it displays in a warning window the following

	Sorry the original item could not be found.
Which indicates to me that my alias data is corrupt.

Two questions

1) What is the correct value for the directparameter keyword?
2) What is wrong in the above code specifically with the creation of the alias?