Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Jul 30, 2013, 05:24 PM   #1
bgrantmyre
macrumors newbie
 
Join Date: Jul 2013
Applescript - Button returned error

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
bgrantmyre is offline   0 Reply With Quote
Old Jul 30, 2013, 07:04 PM   #2
Red Menace
macrumors regular
 
Join Date: May 2011
Location: Littleton, 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.
__________________
MacBook Pro / OS X Mavericks (10.9.4) / Xcode 5.1.1 / RubyMotion FTW
Red Menace is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
How can i make applescript run on a button Intelligent Mac Programming 3 Mar 10, 2014 03:29 PM
Applescript how to check radio button redwgaontoy Mac Programming 1 Jun 18, 2013 08:35 AM
Applescript Safari how to click button redwgaontoy Mac Programming 1 Jun 11, 2013 11:12 PM
AppleScript - Button Returned of Results from a List JPinto Mac Programming 1 Jan 13, 2013 02:02 PM
AppleScript To Click One Button Only If Another Button Is Unavailable JonHimself Mac Programming 2 Jul 4, 2012 12:16 PM

Forum Jump

All times are GMT -5. The time now is 07:28 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC