|
|
#1 |
|
AppleScript opening/tiling two safari windows
Hi, im fairly new to applescript. I want to make a script that will open two Safari windows side by side(tiled) with one window on google.com and another on yahoo.com
So ive been googling various solutions and mixing up different codes to find out a solution. At this point im getting an error with running this applescript, can anyone tell me why? Thanks in advance Code:
application "Safari"
activate
do JavaScript "window.open('http://www.yahoo.com')" in document 1
set bounds of window 1 to {160, 80, 980, 700}
tell application "System Events"
tell process "Safari"
click menu item "New Window" of menu "File" of menu bar 1
set bounds of window 2 to {160, 80, 980, 700}
end tell
end tell
end tell
|
|
|
|
0
|
|
|
#2 |
|
Hi,
You might want to try something like this: Code:
tell application "Safari"
activate
open location "http://www.google.com"
set bounds of window 1 to {10, 123, 513, 457}
make new document
open location "http://www.yahoo.com"
set bounds of window 1 to {513, 123, 1016, 457}
end tell
Tip: To find the bounds of the frontmost Safari window, use this command in a separate AppleScript Editor window: Code:
tell application "Safari" to get bounds of window 1 Once you have your two Safari windows sized and positioned to your satisfaction, run the "get bounds" command on each window in turn, and then copy and paste the results accordingly into your main script. Good luck. Script tested using Mac OS 10.4.11 Last edited by andmr; Jan 11, 2013 at 05:44 PM. |
|
|
|
0
|
|
|
#3 |
|
Alternatively...
If you wanted to be a bit more show-offy, you could calculate the coordinates of the window on the fly. For example:
Code:
tell application "Finder"
--gets the coords of the desktop
set theScreenSize to bounds of window of desktop
end tell
tell application "Safari"
activate
make new document with properties {URL:"http://www.google.com"}
set bounds of window 1 to {0, 0, (item 3 of theScreenSize) / 2, (item 4 of theScreenSize)} --coords of window are calculated from theScreenSize
make new document with properties {URL:"http://www.yahoo.com"}
set bounds of window 1 to {(item 3 of theScreenSize) / 2, 0, (item 3 of theScreenSize), (item 4 of theScreenSize)}
activate
end tell
...note that this will only really work well if you use a single monitor - if you have a second monitor then things get fiddly! |
|
|
|
0
|
![]() |
|
«
Previous Thread
|
Next Thread
»
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
All times are GMT -5. The time now is 10:22 PM.






Linear Mode
