I can’t seem to get a window to close from within a script. If have tried using:
close window “blerf”
close window “blerf” without saving ← there is no document object (but I tried anyway)
close front window
close front window without saving ← again, no document object
Studio Reference points to Cocoa documentation. I don’t know any of the C languages (or Java for that matter). :?
A little background on the project. I am writting a tongue-in-creek “security” program (the kind of thing that you put in your buddy’s Startup Items on April Fools Day – totally harmless, but [hopefully] fun to watch. :twisted: ) I have created multiple Nibs, each linked to different applescript files. I want to have one applescript file act as a “director.” When a window is closed, the “director” will open the next window, let it do its thing, and when it closes, open the next, etc.
I figure that I can use the ‘on idle’ handler in the “director” to periodically get the contents of a user default item that will be modified when a window is open or closed. Unfortunately, if a window won’t close, the “director” never gets any ‘idle’ events sent its way.
The idle handler should be enabled in the File Owner’s (the application) AppleScript settings, not in the individual windows in the NIB. If you set up your NIB this way, no matter what windows are open, the idle handler will be called. If you want the idle handler to behave differently when a specific window is opened, do a check in the idle routine to see if a specific window is visible and, if so, return without completing the rest of the routine. If it isn’t visible, then continue. I think this is what you mean but it’s difficult to know without seeing the project itself.
That’s what I thought. I have set up the idle handler in File Owner’s. Unfortunately, the handler only gets called at the very beginning of the launch. Once a Nib has been loaded, the handler doesn’t seem to get called anymore. I placed a beep command in the idle handler to verify if the handler was getting called or not. I must not be doing something right