OmarKN Posted September 15, 2019 Share Posted September 15, 2019 Hi and good day, How can I position 2 (Safari) webpages, LEFT and the other RIGHT after my ALFRED OPEN URL macro, where I call 2 urls, and I want them side by side. I guess it could also be done with an AppleScript positioner script after launching the pages?! / with best regards, Omar K N Stockholm, Sweden Link to comment
vitor Posted September 15, 2019 Share Posted September 15, 2019 To clarify, are you wanting to open two Safari windows, each on one half of the screen? Link to comment
OmarKN Posted September 16, 2019 Author Share Posted September 16, 2019 Yes, exactly - two Safari windows, each on one half of the screen! Link to comment
vitor Posted September 16, 2019 Share Posted September 16, 2019 And how are you introducing the two URLs? Are you giving them to a Keyword (say, by separating them with commas), or are they always the same? Link to comment
OmarKN Posted September 17, 2019 Author Share Posted September 17, 2019 They are 2 static urls, no keywords. The Alfred macro (hotkey trigger) opens first url1 in Safari, then it opens url2 in a new tab. The intent is to have them side-by-side. Maybe it would be enough to have 1 command of some sorts, so as to open url2 in a new Safari *window* and positioning it to the right half of the desktop. I have this script, but with Safari Tabs I don't know: tell application "Safari" to set bounds of front window to {150, 25, 1368, 1299} / Any assistance would be greatly appreciated! With best regards, Omar KN Link to comment
deanishe Posted September 17, 2019 Share Posted September 17, 2019 (edited) Here's a script that accepts one or more URLs as command-line arguments, and opens windows for each one, evenly distributed across the screen: var safari = Application('Safari'); function screenSize() { return Application('Finder').desktop.window.bounds(); } function openWin(url, bounds) { var doc = safari.Document().make(); doc.url = url; var win = safari.windows[0]; win.bounds = bounds; } function run(urls) { var bounds = screenSize(), height = bounds.height, width = bounds.width / urls.length; var x = 0, y = 0; urls.forEach(function(url) { var bounds = {'x': x, 'y': y, 'width': width, 'height': height}; openWin(url, bounds); x += width; }); safari.activate(); } So if you saved the script as browsers.js, you could use it in a Run Script action (Language = /bin/zsh) like this: urls=("https://www.example.com") urls+=("https://www.othersite.com") urls+=("https://www.someplace.com") /usr/bin/osascript -l JavaScript browsers.js $urls Edited September 17, 2019 by deanishe Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now