Help with applescript or automator.

Hi there


I want to create a template that asks me for certain parameters and enters it into textedit.


in other words i want the script to as or prompt to enter text the user enters it and it types that (in the same line) into the text edit. I also want to chose from the list and whatever is chosen is then also typed into the textedit document (in the same line). Is this possible?


Thanks in advanced

Posted on May 22, 2016 4:06 PM

Reply
14 replies

May 22, 2016 4:24 PM in response to Edry.hilario

Use code such as:


set the_answer to text returned of (display dialog "What text would you like entered?" default answer "")

set the_answer to the_answer & " " & (choose from list {"Option 1", "Option 2"})

tell application "TextEdit"

set paragraph 1 of document 1 to (paragraph 1 of document 1) & the_answer

end tell


(142467)

May 22, 2016 4:40 PM in response to Niel

Niel, thank you so much this helping!


I'm a noob at this and i was wondering if you can help me a bit further since im a noob at this. Im trying to piece a bunch of scrip together is not working well.


See i'm trying to write an email that is always type the same way but with certain different variables hence asking to enter text and selecting from a list.


here is an example email.


"hello,


Im writing to let you know that we shipped the (asks to enter text here and writes into text edit) to (asks to enter text here and enters it into textedit) via (choose from a list and writes selection it into textedit ).


Best,

John appleseed. "


I hope this isn't too much work but if you could help me it would really make my day! 🙂

May 22, 2016 6:11 PM in response to Edry.hilario

For your example, use code similar to:


set the_answer to

"hello,


Im writing to let you know that we shipped the "


set the_answer to the_answer & (text returned of (display dialog "What's the item's name?" default answer "")) & " to "

set the_answer to the_answer & (text returned of (display dialog "What's the item's destination?" default answer "")) & " via "

set the_answer to the_answer & " " & (choose from list {"Option 1", "Option 2"}) & "


Best,

John appleseed. "


tell application "TextEdit"

set paragraph 1 of document 1 to (paragraph 1 of document 1) & the_answer

end tell


(142471)

May 22, 2016 5:16 PM in response to Niel

Sweet man this is awesome!! i have two last questions one.


1) i need to add a hard return into the second line in text edit in order the script to work or this happens which is not a biggie if is not fixable but just want to know if it can be fixed.

User uploaded file

2) can i add another question promp right before "best" iits to add tracking so somethign asking like "what the tracking"


If this is too much i understand you've helped me enough!!!! thank you so much.

May 22, 2016 5:49 PM in response to Niel

see if i move that then wouldnt the tracking appear in before the choosing list. Forgive me for the confusion but the email should read like this


"hello,


Im writing to let you know that we shipped the "prompt 1" to "prompt 2" via "Choose from a list".


Tracking # (promt to ask to input text)


Best,

John appleseed. "


here is what we have so far:


set the_answer to "hello,


Im writing to let you know that we shipped the "


set the_answer to the_answer & (text returned of (display dialog "What's the item's name?" default answer "")) & " to "

set the_answer to the_answer & (text returned of (display dialog "What's the item's destination?" default answer "")) & " via "

set the_answer to the_answer & " " & (choose from list {"Option 1", "Option 2"}) & "


Best,

John appleseed. "


tell application "TextEdit"

set paragraph 1 of document 1 to the_answer

end tell

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

Help with applescript or automator.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.