I need to make an AppleScript that would create a new TextEdit file, type any random text, then a table would pop up and give you two options to choose font of that text, then same with colour, save the file on desktop and close TextEdit.
This is what I have so far, but I came to an end of my knowledge:
tell application "TextEdit"
activate
make new document with properties {text:"XDXDXD"}
set theDesktopPath to the path to the desktop folder as text
tell front document
set font to "Comic Sans MS"
set size to 40
set its color to {65535, 0, 0}
end tell
end tell
I'm not sure how to tell what isn't working from the script above. Can you help with the completion of the script?
Best Answer
This is what I've written based on what was posted as the sample. First I set the filename and the file path of the document to create:
I wrote a display dialog that prompts a linefeed with a timeout and vague validation:
After the entry of text I then tell TextEdit to manipulate the text based on what you've supplied and save it to a file on the desktop:
The script's entire code:
The script as it is is a base and there are far other forms of validation and improvements that can be made such as file existence, text returned testing or dialog testing but I wanted to answer the question.
Edit:
Code for the TextEdit tell modified to include closure of the document, text passed is hard coded as
foobar
:Screenshot of dialog:
Screenshots of the above hard coded tell block and re-opened RTF file:
Code modified to take passed text to dialog and RTF opened: