Use the Record option.
I've been messing around with AppleScripts and i thought it would be nice to make a script that would open a window and go to a spacific site for me, but i can't figure it out. So far all i have is:
tell application "Safari"
activate
make new window
end tell
This is extreamly poor, i understand, but i can't find the command for new window for the life of me, much less a "goto URL" command=\
Use the Record option.
Systems:
• 2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 320 GB hard drive, runs 10.6.8
• 1.6 GHz iMac G5, 1.5 GB RAM, 120 GB hard drive, runs 10.4.11 (out of commission)
• iPhone 4, 16 GB, iOS 4.3.5
safari doesn't support record=\ and neither does IE
Oh. Then drag the little icon next to the URL to the Desktop, and tell Applescript to launch this URL file.
Systems:
• 2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 320 GB hard drive, runs 10.6.8
• 1.6 GHz iMac G5, 1.5 GB RAM, 120 GB hard drive, runs 10.4.11 (out of commission)
• iPhone 4, 16 GB, iOS 4.3.5
what would be the code for that?
Um...
I should think...Code:tell application "Finder" open file "XYZ" end tell
Just record your actions as you open the URL file.
Systems:
• 2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 320 GB hard drive, runs 10.6.8
• 1.6 GHz iMac G5, 1.5 GB RAM, 120 GB hard drive, runs 10.4.11 (out of commission)
• iPhone 4, 16 GB, iOS 4.3.5
This will do what you want.Code:tell application "Safari" activate do JavaScript "window.open('http://www.yahoo.com')" in document 1 end tell
Make sure you retain the http:// and the trailing slash though, otherwise you will get an error page.
< Also Known As aeromusek in places >
< PowerBook | 1.67GHz | 1024MB RAM | 120GB | 17" High Res >
< iPod | 20GB | 3rd gen >
"the show must go on" - the artists of the world
Here's a little script I use that runs automatically every morning before I wake up. Then when I get my mornig coffee I can just sit down and all my news pages, etc are already open. While not strictly an AppleScript, it might help you out. This is a shell script that is launched by cron at a specified time.
1. Create the text file (aake sure its TEXT not RTF) and enter the following:
#!/bin/sh
#
# functions
#
# opennew is a function to create a new Safari window
opennew () {
osascript <<EOF
tell application "Safari"
activate
make new document at beginning of documents
end tell
EOF
sleep 5
}
# open a new Safari window then loads the urls listed below into that new
window.
# note the last url in the list does NOT have a trailing fwd slash
opennew
open "http://url1" \
"http://url2" \
"http://url3" \
"http://url4"
# open another window, load more urls
opennew
open "http://url5" \
"http://url6" \
"http://url7" \
"http://url8"
2. Save the file and change permissions to executable (chmod 755 filename).
3. Setup a cron task to launch the file at a specific time, or you can run it manually
Bookmarks