Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

bgrantmyre

macrumors newbie
Original poster
Jul 30, 2013
1
0
I'm trying to make code which allows me to open my favourite websites with the click of a button, and with all my passwords saved on my mac log in at the same time, i keep experiencing a problem i cant fix when i try to run this all it says is "Can't get button returned of {{button returned:"Facebook"}}." I'm very new to this so can someone help me fix this problem?

tell application "Finder"
set x to {display dialog "Which site would you like to visit?" buttons {"Facebook", "Twitter", "Gmail"} default button 1}
if button returned of the result is "Facebook" then
tell application "Safari"
activate
open location "http://facebook.com/"
tell application "System Events"
activate
keystroke return
end tell
end tell
end if
end tell
 

Red Menace

macrumors 6502a
May 29, 2011
578
226
Colorado, USA
The display dialog command returns a record that contains the name of the button, and can also include returned text and an indication that the dialog gave up, if applicable. By using braces around the command in your assignment statement, you are creating a single item list containing the dialog results - the error is that there is no longer a button returned property, since the record is now just an item in the list.

Since your example script is not using the variable that you assigned the dialog results to, you can just use the statement:

Code:
display dialog "Which site would you like to visit?" buttons {"Facebook", "Twitter", "Gmail"} default button 1

Also note that you don't need Safari for the open location command - that command is from the StandardAdditions scripting addition.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.