Dan Herron writes Thu, 9 Oct 1997 11:31:32 -0700: >What I'd like to do is to be able to close windows, count the number of >open windows, move windows, resize windows, count the number of lines, etc. >I know next to nothing about AppleEvents, which may be the real cause of my >frustration. In the example below, the first two things work (closing >windows.) I'm stuck, though, on getting the third (count the number of >lines) to work. > ># to close a window by name (this works) (curly quotes around "Untitled") >$wind = "obj{want:type(cwin), from:null(), form:name, seld:"Untitled"}"; >$evt = AEBuildAppleEvent("core", "clos", typeApplSignature, "McPL", 0,0, > > "'----': $wind", ) or die $^E; > ># to (try to) count the lines in window 1 (this fails) >$windCnt = "obj {want:type(clin), form:indx, seld:abso(all), from:obj ". > "{want:type(cwin), form:indx, seld:1, from:null()}}"; >$evt = AEBuildAppleEvent("core", "cnte", typeApplSignature, "McPL", 0,0, > > "'----': $windCnt, obj:type(clin) ", ) or die $^E; > >$rep = AESend($evt, kAEWaitReply) or die $^E; > >print "Reply was: ", AEPrint($rep), "\n"; > >AEDisposeDesc $evt; >AEDisposeDesc $rep; The following satisfactorily counts the lines in a BBEdit window: $obj = "obj {want:type(cwin), from:'null'(), form:name, seld:"window_name"}"; $evt = AEBuildAppleEvent('core', 'cnte', 'sign', 'R*ch', 0, 0, "'----':$obj, kocl:type(clin)" ) or die $^E; However it fails with MacPerl. So far as I can see, 'cnte' is not included in the 'core' events for MacPerl. I would have thought "Finder" would have been able to do the job, since the 'aete' resource includes this: @EVENT "count", "Return the number of elements of a particular class within an object", 'core', 'cnte' @REPLY 'long', "the number of elements", REQ, SINGLE, NOENUM @DIRECT 'obj ', "the object whose elements are to be counted", REQ, SINGLE, NOENUM, NOCHANGE @PARAM "each", 'kocl', 'type', "the class of the elements to be counted", REQ, SINGLE, NOENUM But "Finder" seems incapable of 'seeing' a window (let alone what's in it) other than a 'container window' i.e. the window of an open folder. Is this how it should behave I wonder? It seems a bit odd. There also seems to be a problem with MacPerl in that the reply 'hangs up'. For instance, the 'clos' script above works perfectly if kAEWaitReply is replaced by kAENoReply. If it isn't, the script times out, and _then_ the window closes. I find this with a 68K/7.5.1/5.1.3r2 and a PPC/8.0/5.1.4b2. I fear this is not much help. Alan Fry ***** Want to unsubscribe from this list? ***** Send mail with body "unsubscribe" to mac-perl-request@iis.ee.ethz.ch