|
#1
| |||
| |||
| Using applescript to open web browser and go to a site
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=\ |
|
#2
| ||||
| ||||
|
Use the Record option.
__________________ System: • 2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 200 GB hard drive, runs 10.5.6 • 1.6 GHz iMac G5, 1.5 GB RAM, 250 GB hard drive, runs 10.4.11 (slightly out of commission at this time) • iPhone, 4 GB, OS X 2.2.1 |
|
#3
| |||
| |||
|
safari doesn't support record=\ and neither does IE
|
|
#4
| ||||
| ||||
|
Oh. Then drag the little icon next to the URL to the Desktop, and tell Applescript to launch this URL file.
__________________ System: • 2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 200 GB hard drive, runs 10.5.6 • 1.6 GHz iMac G5, 1.5 GB RAM, 250 GB hard drive, runs 10.4.11 (slightly out of commission at this time) • iPhone, 4 GB, OS X 2.2.1 |
|
#5
| |||
| |||
|
what would be the code for that?
|
|
#6
| ||||
| ||||
|
Um... Code: tell application "Finder" open file "XYZ" end tell Just record your actions as you open the URL file.
__________________ System: • 2.5 GHz MacBook Pro Core 2 Duo, 4 GB RAM, 200 GB hard drive, runs 10.5.6 • 1.6 GHz iMac G5, 1.5 GB RAM, 250 GB hard drive, runs 10.4.11 (slightly out of commission at this time) • iPhone, 4 GB, OS X 2.2.1 |
|
#7
| ||||
| ||||
| 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 |
|
#8
| |||
| |||
|
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 |
| Thread Tools | |
|
|