Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!usc!zaphod.mps.ohio-state.edu!wuarchive!decwrl!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Add a sound to 'opening a folder' ? Message-ID: <9395@hoptoad.uucp> Date: 24 Dec 89 09:00:12 GMT References: <175@all41.csc.ti.com> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 53 In article <175@all41.csc.ti.com> smaass@all41.csc.ti.com writes: >I am looking for a way to attach sounds to opening a folder. > >A friend suggested that I look at Soundmaster. Although there are many neat >things that can be done with Soundmaster, I don't see that it will do what I am >looking for. > >Is it possible to do this? Does anybody have solution? Do you mean in the Finder or in Standard File? A fairly straightforward trap patch should do it in either case. In the Finder, the opening of a folder causes a NewWindow call. You can check to see if your patch to the NewWindow trap (installed at INIT time) runs under the Finder by comparing the strings at $2e0 (FinderName) and $910 (CurApName) are the same. If not, jump to the old address. If they are the same, then you should check that the defProc is 0; if not, jump to the old address. If the defProc is eight, you may assume that a folder was opened; play the sound. Then jump to the old address. (This will still work even if Finder starts calling GetNewWindow -- GNW goes through NewWindow.) (It's possible someone else will do a NewWindow with type 8 under the Finder; if so, you will play your sound, but the world will not end. This would likely be a desk accessory; I've checked all the standard DAs in 6.0 and they all use 0. Variation code 8 indicates a zoom box, which is unlikely to be used by a desk accessory.) In Standard File, you have to be a little more subtle. You can tell when a new folder is opened by patching the generic Standard File Package trap. As described in IM v4, the fake item number 103 is passed when a new folder is opened. So your patch is a front-end to Standard File, accepting SFGetFile, SFPGetFile, SFPutFile, and SFPPutFile traps, saving their item filter procedures if any. Then call SFPGetFile or SFPPutFile, with your own item filter in place. This can call the saved item filter procedure (if any; else default), see if the item is still 103, and if so, play the sound. It need not be a tail patch, since you don't need to keep control after the trap -- you have already installed your filter, so you can just replace the filter argument on the stack and jump to the old trap address. (However, this is one of those traps that it's pretty safe to tail patch, since it almost always gets called only from user software, not from the OS.) Of course, both of them can only be done by a programmer. I don't know of any user-type solution, sorry. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Satanic is merely the name they give to the behavior of those who would disrupt the orderly way in which men want to live." -- Gabrielle, THE VAMPIRE LESTAT, Anne Rice