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

Re: Apple Events to the Finder from MCL

	I am trying to send apple events to the finder from MCL and I am having all
	kind of troubles.
	First there was no constant defined for the class of the finder apple events
	which should take the value   'FNDR'. Well, we can get around that.
	Then every time the finder gets the wrong parameters, it crashes MCL
	and if you try to restart it, it freezes the machine.  That might be a problem
	with the Finder not MCL.

	But when I try something very simple, such as sending an apple event to the finder
	to empty the trash or to show the clipboard, the machine freezes if I am 
	waiting for a reply, or returns NIL if no-reply is specified. And in both
	cases nothing happened. I tried to get an error number or string from the returned reply, but I got a message saying that there is no descriptor.

	I am using some of the high level functions defined in the appleevent-toolkit.lisp from the example folder.
	 Here is the simple code I used. If you have any pointers, suggestions, or
	information on this matter, I would appreciate your input. Thanks,

	;;;;;to show the clipboard 

	 (with-aedescs (theEvent theFinder reply)
	    (create-named-process-target theFinder "Finder")
	    (apply 'create-appleevent theEvent :|fndr| :|shcl| theFinder ())
	  (send-appleevent theEvent reply :reply-mode :wait-reply)

	Mamdouh H. Ibrahim,       - Electronic Data Systems
			            Artificial Intelligence Services

I also have been looking at Appleevents although without the toolkit you
refer to, and indeed paying for your mistakes with crashes seems to be
part of the scheme of things.  I am absolutely not an expert on this
stuff but here is a successful expression that will bring up the "About ..."
dialog box.  While this is as I got it from my Mac, I tried replacing
kCoreEventClass with kaeFinderEvents, :|FNDR|, and aeAbout with
aeShowClipboard, :|shcl|, and it did the right thing.  Best of luck,
Cris Johnson 
Price Waterhouse Technology Centre 
68 Willow Road, Menlo Park, CA 94025 
(415) 322-0606

(defmacro with-no-osErr (trap-form)
  (let ((err (gensym)))
    `(let ((,err ,(cons 'require-trap trap-form)))
       (when (< ,err #.#$noErr) 
         (error "~A failed (~A)" (quote ,(car trap-form)) ,err))

(defconstant $kFinderSignature    :|MACS|)
(defconstant $aeAbout             :|abou|)

(rlet ((request-event :aeDesc))
  (rlet ((target :aeDesc))
    (rlet ((signature :ostype))
      (%put-ostype signature $kFinderSignature)
        (#_aeCreateDesc #$typeApplSignature signature (record-length :osType) target)))
    (#_aeDisposeDesc target))
  (rlet ((reply-event :aeDesc))
       (logior #$kAEWaitReply #$kAECanInteract #$kAECanSwitchLayer)
    (#_aeDisposeDesc reply-event))
  (#_aeDisposeDesc request-event)