I’m trying to write script that would get the current Safari tab and open it in a new window.
I also want it to move the bounds of the new window to the right slightly (compared to the previous window), and close that tab/URL in the ‘old window’.
tell application "Safari" to set theBounds to the bounds of window 1
tell theBounds to set {leftEdge, topEdge, rightEdge, bottomEdge} to {item 1, item 2, item 3, item 4}
set newWindowBounds to "({" & (leftEdge + 100) & ", " & topEdge & ", " & (rightEdge + 100) & ", " & bottomEdge & "} as rectange)"
tell application "Safari"
set theURL to URL of current tab of front window
set newWindow to make new document at end of documents
set URL of newWindow to theURL
set the bounds of window 1 to newWindowBounds
-- -> error number -1700 from "({551, 25, 1652, 993} as rectange)" to rectangle
close current tab of window 2
end tell
The script runs OK until it gets to setting the bounds of the new window, it then throws an error:
I’m hoping the problem is something simple. Does anyone know why I get the error?