I am trying to make a script so when you run it, it asks you if you would like to go on Twitter. If you say yes, a new message pops up. The problem I am having is the next message that asks you what you will tweet, so you put in the information. Then you press done. The problem is when you press done, I am getting an error that says "Can't get buttoned returned of {whatever message I put into the text box.} The next thing is that, if somebody helps me with this part, how do I get the text entered to be put into the actual "Compose New Tweet" box on Twitter. This works great if I do not have the second message, but you have to manually put in your message in the script on the bottom, which I do not want. Please, somebody help me because I really want this to work and this will be the first pretty cool thing I have made with an Apple Script. Thanks!
Here is my code:
Here is my code:
Code:
say "Would you like to go on Twitter and say hello?"
display dialog "Would you like to go on Twitter and say hello?" buttons {"Yes", "No"}
set button_r to the button returned of the result
if the button_r is "yes" then
say "What would you like to tweet?"
set theName to the text returned of (display dialog "What would you like to tweet?" default answer "" buttons {"Done", "Nevermind"})
set button_w to the button returned of the result
if the button_w is "Done" then
tell application "Safari"
activate
end tell
delay 1
tell application "Safari"
open location "https://www.twitter.com"
end tell
delay 1.5
tell application "System Events"
tell process "Safari"
tell window 1
tell group 2
tell group 1
tell group 1
tell scroll area 1
tell UI element 1
tell group 3
tell group 2
tell list 1
tell group 3
click button 1
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
tell application "System Events"
display dialog theName
keystroke "(Your Message)"
end tell
delay 1
tell application "System Events"
tell process "Safari"
tell window 1
tell group 2
tell group 1
tell group 1
tell scroll area 1
tell UI element 1
tell group 20
tell group 1
tell toolbar 1
tell group 2
click button 1
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end tell
end if
if the button_r is "No" then
end if
if the button_w is "Nevermind" then
end if
end if