[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Apple Events to the Finder from MCL
- To: info-mcl@cambridge.apple.com, mhi@ais.tsd.eds.com
- Subject: Re: Apple Events to the Finder from MCL
- From: cdj@tc.pw.com (Cris Johnson)
- Date: Thu, 26 Sep 91 18:16:18 PDT
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))
,err)))
(defconstant $kFinderSignature :|MACS|)
(defconstant $aeAbout :|abou|)
(rlet ((request-event :aeDesc))
(rlet ((target :aeDesc))
(rlet ((signature :ostype))
(%put-ostype signature $kFinderSignature)
(with-no-OSErr
(#_aeCreateDesc #$typeApplSignature signature (record-length :osType) target)))
(with-no-osErr
(#_aeCreateAppleEvent
#$kCoreEventClass
$aeAbout
target
#$kAutoGenerateReturnID
#$kAnyTransactionID
request-event))
(#_aeDisposeDesc target))
(rlet ((reply-event :aeDesc))
(with-no-osErr
(#_aeSend
request-event
reply-event
(logior #$kAEWaitReply #$kAECanInteract #$kAECanSwitchLayer)
#$kAENormalPriority
#$kAEDefaultTimeout
(%null-ptr)
(%null-ptr)))
(#_aeDisposeDesc reply-event))
(#_aeDisposeDesc request-event)
)