使用applescript将所有打开的应用程序移动到当前桌面“空间”

时间:2019-04-04 13:22:15

标签: macos applescript desktop display

我一直在无休止地搜索如何在applescript中的macOS上的空格之间移动窗口。我想做的看似基本的事情是将所有打开的应用程序窗口从任何空间移到第一个空间。如果有人可以提供帮助,请与我们联系。在最新版本的macos(Mojave 10.14.4)中似乎没有直接的方法。如果可能/更简单,我也可以使用任何其他可与macos交互的语言来做到这一点。

tell application "System Events"
    repeat with proc in application processes where background only is false
        tell proc
            log "found app: " & name
            set processName to name
            log count of windows
            repeat with win in windows
              -- move window to first "space"
            end repeat
        end tell
    end repeat
end tell

2 个答案:

答案 0 :(得分:0)

我认为做到这一点的唯一方法就是使用 tell application "System Events" to key code 19 using {control down} 但是随后您的桌面就会为每个应用疯狂跳动。

答案 1 :(得分:0)

有一个名为Phoenix的macOS窗口管理器,可使用JavaScript编写脚本。

我写了一个Phoenix脚本phoenix-move-windows,该脚本根据当前监视器和屏幕布局移动窗口。它是可配置的,以便将窗口移动到指定位置,并且您可以根据当前屏幕数和每个屏幕上的空格数进行不同的安排。

它确实支持使用排列中的“ defaultBinding”将所有窗口移动到指定的屏幕和空间。