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

SChaput

macrumors regular
Original poster
Jul 2, 2008
153
0
United States
I'm writting a quick apple script to try and paste some user inputed information into safari. Below is my code:
Code:
set thePrefix to ""
set theNumber to ""
set theIcon to note
display dialog "Please Enter The URL:" default answer ""
set theNumber to text returned of result
set the clipboard to theNumber

tell application "Safari"
	make new document at end of documents
	activate "Safari"
	set URL of document 1 to "http://www.facebook.com" 
	keystroke "v" using {command down} 

end tell
I'm trying to copy the user input to the clipboard, which works, but when i try to paste it into the URL i get the error:
Expected end of line but found identifier

Can anyone shed any light on this?

Thank you!
 
Some light...

Hi,

here you go:

Code:
set thePrefix to ""
set theNumber to ""
set theIcon to note
display dialog "Please Enter The URL:" default answer ""
set theNumber to text returned of result

tell application "Safari"
	activate
	make new document at end of documents
	set URL of document 1 to "http://www.facebook.com/" & theNumber
end tell

keystroke is a part of "System Events" dictionary, then you have to call it this way:
Code:
tell application "System Events"
	tell process "Safari"
		keystroke "v" using {command down}
	end tell
end tell
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.