bengr Posted April 25, 2013 Posted April 25, 2013 (edited) Hey, I saw a workflow request on /r/Alfred that interested me as well, and saw that no one made it yet, so I quickly wrapped up one with a little bit of Google-ing. Basically, it's a really basic workflow that moves your current window between monitor(s) with the tap of a hotkey or by entering "jump" into Alfred (both are configurable of course). I don't think I'll be maintaining this workflow, as there really is not much to maintain, it's a very simple AppleScript behind, but feel free to comment here and I'll check it every once in a while to see if anything is needed. Download Edited April 25, 2013 by The_Ben CarlosNZ and addEdgeBookmarkSearch 2
Ddyracer Posted April 25, 2013 Posted April 25, 2013 Hey, I saw a workflow request on /r/Alfred that interested me as well, and saw that no one made it yet, so I quickly wrapped up one with a little bit of Google-ing. Basically, it's a really basic workflow that moves your current window between monitor(s) with the tap of a hotkey or by entering "jump" into Alfred (both are configurable of course). I don't think I'll be maintaining this workflow, as there really is not much to maintain, it's a very simple AppleScript behind, but feel free to comment here and I'll check it every once in a while to see if anything is needed. Download Wish I could use it... Too bad Apple screwed my monitor up in 10.8.3.
stonefury Posted September 9, 2013 Posted September 9, 2013 I position my laptop below my larger monitor, so it won't work for this case. Will be easy to fix, just mentioning in case there was a way to better identify the monitor to move the window to. CarlosNZ 1
spacecadet9 Posted September 11, 2013 Posted September 11, 2013 This works great for me Thanks very much, really handy
mikeymo Posted July 31, 2015 Posted July 31, 2015 THANK YOU for this workflow—does exactly what I need with zero cruft. Much appreciated.
Ptujec Posted April 10, 2021 Posted April 10, 2021 (edited) Hi you might be interested in this. I build it for LaunchBar. But since it is just an applescript you should be able to make it work just fine in Alfred with just a few changes. It's a few lines of code. But it should cover pretty much all the bases. # http://superuser.com/questions/331313/how-to-automagically-move-windows-between-monitors-with-one-keystroke # https://stackoverflow.com/questions/6565703/math-algorithm-fit-image-to-screen-retain-aspect-ratio # https://forum.latenightsw.com/t/get-sizes-of-monitor-s-via-applescript/1351/10 --- use framework "Foundation" use framework "AppKit" use scripting additions set allFrames to (current application's NSScreen's screens()'s valueForKey:"frame") as list try set _mon1 to item 2 of item 1 of allFrames set _mon2 to item 2 of item 2 of allFrames set _mon1Width to item 1 of _mon1 set _mon1Hight to item 2 of _mon1 set _mon1Size to _mon1Width + _mon1Hight set _mon2Width to item 1 of _mon2 set _mon2Hight to item 2 of _mon2 set _mon2Size to _mon2Width + _mon2Hight set _screenWar to (_mon2Width / _mon1Width) # width adaption ratio of screen 1 & 2 set _screenHar to (_mon2Hight / _mon1Hight) # hight adaption ratio of screen 1 & 2 tell current application to set _hightoffset to do shell script "/usr/libexec/PlistBuddy -c 'Print :DisplayAnyUserSets:Configs:0:0:CurrentInfo:OriginY ' /Library/Preferences/com.apple.windowserver.displays.plist" set _hightoffset to _hightoffset as feet as number tell current application to set _widthoffset to do shell script "/usr/libexec/PlistBuddy -c 'Print :DisplayAnyUserSets:Configs:0:0:CurrentInfo:OriginX ' /Library/Preferences/com.apple.windowserver.displays.plist" set _widthoffset to _widthoffset as feet as number # detect position of the second screen in relation to the main screen if _mon1Width = _widthoffset then # say "Rechts" set _right to true else if _mon1Hight = _hightoffset then set _right to false set _bottom to true else if _mon2Width = -_widthoffset then set _right to false set _bottom to false set _left to true else if _mon2Hight = -_hightoffset then set _right to false set _bottom to false set _left to false set _top to true end if end try try tell application "System Events" tell (first process whose frontmost is true) set _windowPos to position of window 1 set x to item 1 of _windowPos # x = position width set y to item 2 of _windowPos # y = position hight set _windowSize to size of window 1 set _windowWidth to (item 1 of _windowSize) set _windowHight to (item 2 of _windowSize) # set current location (which monitor) of the frontmost window and new window size and postion if _right is true then if x < _mon1Width then set _newSize to {_windowWidth * _screenWar, _windowHight * _screenHar} set _newPosition to {(x * _screenWar) + _widthoffset, ((y - 25) * _screenHar) + (_hightoffset + 25)} # menubar = 25 pixel set _winLocation to "mon1" else set _newPosition to {(x - _widthoffset) / _screenWar, ((y - (_hightoffset + 25)) / _screenHar) + 25} set _newSize to {_windowWidth / _screenWar, _windowHight / _screenHar} set _winLocation to "mon2" end if else if _bottom is true then if y < _mon1Hight then set _newPosition to {(x * _screenWar) + _widthoffset, ((y - 25) * _screenHar) + (_hightoffset + 25)} set _newSize to {_windowWidth * _screenWar, _windowHight * _screenHar} set _winLocation to "mon1" else set _newPosition to {(x - _widthoffset) / _screenWar, ((y - (_hightoffset + 25)) / _screenHar) + 25} set _newSize to {_windowWidth / _screenWar, _windowHight / _screenHar} set _winLocation to "mon2" end if else if _left is true then if x > -1 then set _newSize to {_windowWidth * _screenWar, _windowHight * _screenHar} set _newPosition to {(x * _screenWar) + _widthoffset, ((y - 25) * _screenHar) + (_hightoffset + 25)} set _winLocation to "mon1" else set _newPosition to {(x - _widthoffset) / _screenWar, ((y - (_hightoffset + 25)) / _screenHar) + 25} set _newSize to {_windowWidth / _screenWar, _windowHight / _screenHar} set _winLocation to "mon2" end if else if _top is true then if y < 25 then set _newPosition to {(x - _widthoffset) / _screenWar, (y + (-_hightoffset - 25)) / _screenHar + 25} set _newSize to {_windowWidth / _screenWar, (_windowHight + 25) / _screenHar - 25} set _winLocation to "mon2" else set _newSize to {_windowWidth * _screenWar, (_windowHight + 25) * _screenHar - 25} set _newPosition to {(x * _screenWar) + _widthoffset, ((y - 25) * _screenHar) + _hightoffset + 25} set _winLocation to "mon1" end if end if # checking for window loaction and whether the monitor it is located on is bigger or smaller than the other one if _winLocation is "mon1" then if _mon1Size > _mon2Size then set size of window 1 to _newSize set position of window 1 to _newPosition else set position of window 1 to _newPosition set size of window 1 to _newSize end if else if _mon2Size > _mon1Size then set size of window 1 to _newSize set position of window 1 to _newPosition else set position of window 1 to _newPosition set size of window 1 to _newSize end if end if end tell end tell end try There are more window actions on my github. Under the hood they are all applescripts https://github.com/Ptujec/LaunchBar/tree/master/Window%20Actions Edited April 14, 2021 by Ptujec
Ptujec Posted April 14, 2021 Posted April 14, 2021 On 9/10/2013 at 12:51 AM, stonefury said: I position my laptop below my larger monitor, so it won't work for this case. Will be easy to fix, just mentioning in case there was a way to better identify the monitor to move the window to. Check my script below. This should work no matter how you position monitors or whether one is bigger or smaller … as long as it's just two. Didn't try it for more. If you are still interested 7 years + later
krishnan Posted October 2, 2022 Posted October 2, 2022 (edited) Thanks for the script! I tried running it in macOS Monterey and got the following error: ERROR: Print: Entry, ":DisplayAnyUserSets:Configs:0:0:CurrentInfo:OriginY", Does Not Exist I tried google-ing and couldn't find anything related to this error, did the name of DisplayAnyUserSets Configs change in the latest update? Edited October 2, 2022 by krishnan
vitor Posted October 2, 2022 Posted October 2, 2022 With Alfred 5 you don’t need a script for it, there is an Automation Task under Window Management which does it.
TomBenz Posted October 3, 2022 Posted October 3, 2022 1 hour ago, vitor said: With Alfred 5 you don’t need a script for it, there is an Automation Task under Window Management which does it. Yes, I shifted to using automation tasks. I also have one for removing windows from full screen, shift to other monitor and then again to full screen. Automation task is great in Alfred 5
TomBenz Posted July 9, 2023 Posted July 9, 2023 On 10/3/2022 at 6:12 AM, TomBenz said: Yes, I shifted to using automation tasks. I also have one for removing windows from full screen, shift to other monitor and then again to full screen. Automation task is great in Alfred 5 @vitor How do I use automation task to get and move all windows from one monitor to other? When I am sharing screen on teams, I would like only teams app windows to remain on primary montior (retina display) and move everything else on other monitor. Suggest how this can be done. Thanks in advance
sosaveme Posted July 9, 2023 Posted July 9, 2023 Is it possible to move fullscreen app or fullscreen video?
TomBenz Posted July 10, 2023 Posted July 10, 2023 10 hours ago, sosaveme said: Is it possible to move fullscreen app or fullscreen video? You can use Automation tasks to create a workflow for this. Steps are keyword or shortcut to trigger --> key combo (ctrl + command + F) to move the window out of full screen mode, move to next monitor and again make the app full screen.
sosaveme Posted July 10, 2023 Posted July 10, 2023 6 hours ago, TomBenz said: You can use Automation tasks to create a workflow for this. Steps are keyword or shortcut to trigger --> key combo (ctrl + command + F) to move the window out of full screen mode, move to next monitor and again make the app full screen. Thanks! Sadly but this method doesn't work properly for safari full screen video, because it's move whole safari
TomBenz Posted July 10, 2023 Posted July 10, 2023 11 minutes ago, sosaveme said: Thanks! Sadly but this method doesn't work properly for safari full screen video, because it's move whole safari Hope @vitor or other experts will get to answer mine as well as your question.
sosaveme Posted July 10, 2023 Posted July 10, 2023 8 minutes ago, TomBenz said: Hope @vitor or other experts will get to answer mine as well as your question. Don't think it's possible because Apple allow move spaces only with trackpad gestures.
vitor Posted July 10, 2023 Posted July 10, 2023 @TomBenz That is quite complex and specific, especially because you’re wanting to move every window not belonging to an app. That needs a bespoke solution. @sosaveme It’s not possible to do that, even manually. The video is part of the tab/window it comes from. And indeed, Apple does not provide an API to programatically move between spaces.
TomBenz Posted July 10, 2023 Posted July 10, 2023 4 hours ago, vitor said: @TomBenz That is quite complex and specific, especially because you’re wanting to move every window not belonging to an app. That needs a bespoke solution. @sosaveme It’s not possible to do that, even manually. The video is part of the tab/window it comes from. And indeed, Apple does not provide an API to programatically move between spaces. Thanks @vitor for your response. Is it possible to move all windows without exception then? I can then manually move teams windows back to main window? https://stackoverflow.com/questions/20554602/applescript-get-list-of-windows-on-all-desktops/67338053#67338053 I see this AppleScript to get list of windows -- How can this combined with move automation task or modified to achieve this/
TomBenz Posted July 10, 2023 Posted July 10, 2023 Just now, TomBenz said: Thanks @vitor for your response. Is it possible to move all windows without exception then? I can then manually move teams windows back to main window? https://stackoverflow.com/questions/20554602/applescript-get-list-of-windows-on-all-desktops/67338053#67338053 I see this AppleScript to get list of windows -- How can this combined with move automation task or modified to achieve this/ would be great if somebody can guide / help or write a workflow for it.
Stephen_C Posted July 10, 2023 Posted July 10, 2023 2 minutes ago, TomBenz said: would be great if somebody can guide / help or write a workflow for it. I really would simply use something like Moom. Sometimes it's better to use something specifically designed for a task rather than trying to reinvent the wheel. Stephen
TomBenz Posted July 10, 2023 Posted July 10, 2023 20 minutes ago, Stephen_C said: I really would simply use something like Moom. Sometimes it's better to use something specifically designed for a task rather than trying to reinvent the wheel. Stephen thank you @Stephen_C. I had used this app once before and will try again. Will this be able to move all windows in one go? I also use Rectangle (moved to this from Spectacle) but find windows management workflow via Alfred itself easy to use and update.
Stephen_C Posted July 10, 2023 Posted July 10, 2023 13 minutes ago, TomBenz said: I had used this app once before and will try again. Will this be able to move all windows in one go? I'm not sure this is a subject for this forum: we risk derailing the thread. However, on the page to which I previously linked read the section headed "Save and restore window layouts”, which includes the following: Quote This feature is particularly useful if you use a laptop with an external display—Moom can trigger saved layouts on addition or removal of displays. I use that feature and it works well. Stephen TomBenz 1
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