tell application "System Events"
set theButtons to {}
repeat with theApplication in application processes
repeat with theWindow in windows of theApplication
repeat with theButton in buttons of theWindow
if ((description of theButton) is "minimize button") then
set theButtons to theButtons & {theButton}
end if
end repeat
end repeat
end repeat
repeat with theButton in theButtons
click theButton
end repeat
--do it twice because it usually misses one the first time
repeat with theButton in theButtons
click theButton
end repeat
end tell
I got this from my scripts folder, there's whole bunch of junk in there and this one looks like it minimizes
all open windows, but you should be able to figure it out.
Off the top of my head, an easier one might be:
tell app "terminal"
activate
tell app "system events"
type "m" with command down
end tell
end tell
(I'm at work on a windows box and I can't test the syntax, so fool around with that.)