Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ManuCH

macrumors 68000
Original poster
May 7, 2009
1,599
1,204
Switzerland
So I was wondering if there's a way to achieve the following, as I searched but didn't find a way.

I would like to create a shortcut (or anything else that works) which moves all windows of the apps I specify to another desktop.

I usually use my Mac with only 1 desktop, but when I am at work, I use 2 desktops (one for the private apps, one for the work apps). I would like to move all the work apps to the work desktop with 1 click, the moment I arrive at work.

Is there any way to do that at all?

Thank you 😊
 

ManuCH

macrumors 68000
Original poster
May 7, 2009
1,599
1,204
Switzerland
Thank you for pointing me to the right direction, this allowed me to solve it! I did the following in AppleScript:

AppleScript:
tell application "System Events"
    tell process "Dock"
        set frontmost to true
        activate
        tell list 1
            perform action "AXShowMenu" of UI element "Google Chrome"
            delay 0.1
            repeat 4 times -- count number of items to the one you want
                key code 126 -- up arrow
            end repeat
            key code 124 -- right arrow
            repeat 4 times
                key code 125 -- down arrow
            end repeat
            key code 36 -- return
        end tell
    end tell
end tell
 
  • Like
Reactions: bogdanw
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.