Can't close a window

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.

As always, thanks in advance,
Brad Bumgarner, CTA

Try:

Jon


[This script was automatically tagged for color coded syntax by Script to Markup Code]

Will hiding the window release it so that idle events will be sent to the application?

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.

Jon

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 :cry:

Again, seeing the project would help.

Jon

Jon,

You’ve given me some things to look at and make SURE I’ve got set up properly. If I still can’t get it going I’ll get you the project.

Thanks,
Brad Bumgarner, CTA

It’s official: I’m an idiot! :rolleyes:

In my idle handle I forgot to add the “return 1” statement. After I added that, low and behold, I started getting idle events.

Thanks for all of your help Jonn.
Brad Bumgarner, CTA