Reading TextEdit window without saving?

The title says it all: I want my Applescript to read the contents of a TextEdit window WITHOUT saving the document. Reading TextEdit files are easy, but it’s the window I want. Is there a way to do this? If you know of any apps that support such functionality better than TextEdit, I’d welcome the suggestion. Thanks!

Hello.

tell application "TextEdit" to if (count its documents) > 0 then
	set theText to text of its front document
else
	set theText to ""
end ifl

That is it, it grabs the text of the front window of Text Edit.

Perfect. You are awesome. Thank you!

Hello.

I added a test for open documents, while you replied. :slight_smile: