This works except for the exit quick mask mode.
Anyone else been able to do it?
tell application "Adobe Photoshop CS5"
activate
tell front document
if (quick mask mode) then exit quick mask mode
end tell
end tell