Hey David,
Good to know.
So I see.
It lacks some niceties like:
tell application "TextWrangler"
close every document without saving
end tell
OR
tell application "TextWrangler"
close every document with saving
end tell
If you use Triumph a lot I suggest you invest some time in learning how to script it. You may not have time for it on this job, but it will pay dividends in future.
Triumph will handle this:
tell application "Triumph" to close every document
But if you have unsaved changes in a window it will ask if you want to save them.
Nevertheless you can either use the AppleScript + Keyboard Maestro to hit ‘Don’t Save’ buttons (if needed).
Or you can loop through Triumph’s windows in KM and press Cmd-W and press the ‘Don’t Save’ button if necessary.
However, it’s nicer when you can talk directly to the app. (You might mention the need to the developer for close without saving.)
System Events can do the job effectively if a bit slower than regular AppleScript:
# Close every document window WITHOUT saving.
tell application "System Events"
tell application process "Triumph"
set frontmost to true
set winList to windows whose attribute "AXSubrole"'s value is "AXStandardWindow"
repeat with theWindow in winList
tell theWindow
perform action "AXRaise"
tell (first button whose description is "close button")
if value of attribute "AXEdited" is true then
click
delay 0.1
tell theWindow to click button "Don’t Save" of sheet 1
else if value of attribute "AXEdited" is false then
click
end if
end tell
end tell
end repeat
end tell
end tell
* Only tested on Mavericks.
It should close any open windows AND click the ‘Don’t Save’ button if necessary.
A bit of a pain to figure out — impossible to figure out without having access to the app — there is a demo.
So, a restart script might go something like this:
set closeWindows to false
tell application "Triumph"
if not running then
run
set closeWindows to true
end if
activate
end tell
delay 0.25
if closeWindows then
tell application "System Events"
tell application process "Triumph"
set frontmost to true
set winList to windows whose attribute "AXSubrole"'s value is "AXStandardWindow"
repeat with theWindow in winList
tell theWindow
perform action "AXRaise"
tell (first button whose description is "close button")
if value of attribute "AXEdited" is true then
click
delay 0.1
tell theWindow to click button "Don’t Save" of sheet 1
else if value of attribute "AXEdited" is false then
click
end if
end tell
end tell
end repeat
end tell
end tell
end if
* Only tested on Mavericks.
-Chris