How to save AppleScript Editor Documents? I try to save script in front most window in AppleScript Editor to desktop as text without using GUI scripting.

tell application "AppleScript Editor" to save contents of document 1 as text in ((path to desktop) &amp; "test.txt" as string)
To save it as a .scpt file for AppleScript Editor:

tell application "AppleScript Editor"
    save document 1 as "script" in file ((path to desktop as Unicode text) &amp; "Hello.scpt")
end tell


To save as a plain .txt file, just change the middle line slightly

tell application "AppleScript Editor"
    save document 1 as "text" in file ((path to desktop as Unicode text) &amp; "Hello.txt")
end tell