AppleScript questions: speed it up with xcode? miniaturized property?

Hi

I am new to Mac (Lion 10.7.2), and am playing around with AppleScript. I have the following script that minimizes all visible windows:
Code:

tell application "System Events"
	--Get all the available applications that can be visible
	repeat with appProc in (every application process whose visible is true)
		--From the available applications above, click on the minimize
		-- button of every window that has a minimize button
		click (first button of every window of appProc whose role description is "minimize button")
	end repeat
end tell

Here are my problems and quesions…

The script does work, except it is kind of slow, meaning instead of instantly minimizing all the windows, you watch each one get minimized one by one. I tried saving it as an application from AppleScript Editor, but then it is really really slow (takes about 5 to 10 seconds before it even starts doing anything).

QUESTION #1
Can this script be imported into Xcode and be converted to an app that will run much faster?

QUESTION #2
I was looking for other ways to do this instead of “click button”, and I found references to the miniaturized property of the window, but this property and the miniaturizable property both do not appear to exist when I view the properties of applications and windows. I have searched google for hours about this, and cannot figure out why it is not availble.


Questions #3 and #4 I was about to ask, but found answers a few minutes ago, and thought I would post because they are related:

ANSWERED QUESTION #3
How can I create an alias on the desktop (to the .scpt file), that when clicked, will run the script instead of opening it up in AppleScript Editor? I do not want to the Script Menu in the menu bar to run the script.

ANSWERED QUESTION #4:
Can AppleScript be iimported into Automator and converted to an application?

ANSWER for Question #3 and #4:
Start Automator, choose new Application and then drag the Run Applescript Action over to the right hand side and then copy and paste your applescript into it and save it. You now have an application that runs just as fast as the original applescript, and you can also create an alias on your desktop to it.

Thanks

Yes this can be imported into an AppleScriptObjC project but I doubt it will be faster than an ‘execute-only’ script.

Can’t you just hide the application instead? or need every window to be in the dock per se?

It’s not an alias, you need to save the script as an application or execute only script or script bundle to run instead of opening in script editor. NOTE: applications can be opened (when execute only flag is off) by opening the file from the open menu or dragging it onto the application. When the execute-only flag is turned on you can’t open them after you’ve closed the document.

Somebody finally figured out how to Show Desktop correctly:
http://www.everydaysoftware.net/showdesktop/index.html

Exposé has done that since 10.5, I think - F11, or fn-F11 on an alu keyboard.
In 10.7 (which I do not have) those functions are now in Mission Control.

No, Expose and Mission Control do NOT do it properly (well not the way I want it done) … they just move everything to the outside edges.

With the script above, it hides/minimizes all windows instantly, which is different than how OS X has tried to do it.