I wasn’t aware that anything in windows worked according to ‘common sense’. People like me who abhor windows consider many things that windows does to be outside the realm of common sense. While every platform has it’s merits (some less than others ) you’d be hard-pressed to get me to agree that quitting an app because it’s last window just closed should be a default behavior. While sometimes it saves me a step to not have to quit it manually, I’m of the opinion that most apps should stay open until I tell them not to be. Sometimes, the frontmost running app is important even though it may not have any windows. I realize that’s why you’d prompt the user before quitting, but that’s kind of beside the whole concept behind how this OS works. Take for example, the Finder. The finder could go for days without ever showing a window, but never in that time would I want to quit it. In fact, of all of the 6 apps showing in my dock right now as active, only firefox is actually in use. But, in 2 minutes when I’m done writing this, I still want all 6 of them running, even though I won’t be using but 1 or 2 at a time. While you could obviously test for certain key apps before displaying your alert, it seems you’d end up creating more confusion, and using more memory running a script or app to check for windowed processes. Being a long-time mac user, I would NEVER assume that because a window closes that the whole app goes away. In fact, I rather value the ability to close an app’s window but still have it running… waiting patiently and respectfully for me to use it again should I so choose. If I had to wait for apps like photoshop to launch every time I opened an image, I think I’d have to shoot myself. And I certainly wouldn’t want some script asking me every so often if I wanted to quit it just because I don’t happen to be working on something in it at the moment.
While I see that there might be some novelty to this, as you said this is probably not of much use to people who already know what’s going on with their mac. As far as memory ‘hogging’ goes, I find it hard to believe that the performance is so significantly limited by running even a handful of apps in rosetta. Eventually, most significant apps should be made available as universal binaries, so that should take care of most of the problems. Regardless, it seems kind of beside the point of having a core duo machine that processes so significantly faster. If you’ve got problems running apps, I’d put more memory in before I’d piddle over closing apps just to save a couple mb of ram.
There are also some technical details that need to be addressed. First does the script run in the background ALL the time? This would be the only way to logically use the app. Otherwise, you’d have to run it, which would be just as easy or easier than just quitting the app manually. The other thing, is that your app will steal focus every time it needs to display a message. It can’t display a dialog in the background, although it could possiblly try to display the dialogs through the apps it’s trying to quit. Sounds dangerous, though. What if you don’t want to quit the app? Does it record that and not ask you again? How often do you check for frontmost app? What if you change apps before the next check, and the app you closed the window to is now in the background somewhere? That app will then stay open until you go back to it and wait for your check to happen. Also, many apps have “windows” when there aren’t actually any ever on screen in the course of using the app. While you could test for visible windows, sometimes there are windows in the applications memory, off screen, in the dock, or carbon apps with no windows accessible to applescript, etc… that technically count as windows but are never visible. From a programmatic point of view, you may end up running into conflicts… or just plain annoying yourself… by trying to determine whether the windows exist, and whether you want to evaluate them as valid windows or not. There are lots of details that are unclear, but enough to make managing this whole system quite a bit more complex than a couple simple lines of code. While a simple idle script that displays a message is easy to write, you’ll find pretty quickly that it’s more of a pain to deal with it asking you to quit everything than it is to just work until you notice things getting a bit slow and just quitting the apps yourself.
Everyone has some sort of mechanism for managing open apps… i.e. the dock or a similar app launcher… that should give you easy access to all of the windowed, user processes. It doesn’t take long to learn how to click on an icon and quit an app if you’re not using it any more. I do think it’s a good idea to avoid having too many apps open at once. In the course of everyday use, my machine gradually takes on more and more unreleased memory. Because of poor memory management by apps… including apple’s apps… the ram usage slowly builds on every machine. On a day of serious development, especially when I’m working on memory management of my own, I might have to restart a couple times to clear the ram and boost my processing and rendering speeds. This has less to do with how many apps are open and more to do with what kind of apps are open and what they do.
I certainly don’t want to rain on your parade, it just seems like such an unnecessary step to have to take. If you were to write it as a background app/daemon that ran outside the windowed process realm, you might actually have something remotely useful (for you). This would also give you the ability to do some more complex things with your interface. Perhaps popping up a list of all processes a little less frequently would be better, and quitting all selected at once… just to do a ‘purge’ of unused apps. Might make it easier and more predictable than trying to deal with just the frontmost app.
j