【问题标题】:Move all windows to a single monitor (with two attached) in Mac OS X? [closed]在 Mac OS X 中将所有窗口移动到单个监视器(连接两个)? [关闭]
【发布时间】:2010-09-07 12:47:24
【问题描述】:

每当我在远离办公桌的地方使用 MacBook,然后将其插入外接显示器(作为主显示器)时,我都会进入笔记本显示器和外接显示器中都有窗口的状态。

要将所有窗口移动到单个屏幕,我目前的解决方案是在显示首选项中“打开镜像”,然后再次将其关闭。不过,这相当乏味。有谁知道更好的方法吗?


恐怕@erlando 发布的脚本对运行 Mac OS X 10.5.4 的我来说完全没有任何作用。 (即,在两个屏幕上都有窗口,运行脚本不会移动其中一个,并且它不会返回任何错误。)我想我只需要坚持使用上面提到的“镜像/取消镜像”方法。


@Denton: 恐怕这些链接提供了脚本,用于将 any 屏幕上的孤立窗口重新显示到显示器上。我“只是”想将所有窗口从辅助显示器移动到主显示器。

【问题讨论】:

  • 现在这个问题不应该转移到以用户为中心的 SE 网站上吗? SO 是针对编程问题的,这不是一个。
  • 当您甚至无法发表评论时回顾旧问题很有趣,因此不得不将它们附加到问题本身:)
  • 在 10.15.5 上打开和关闭镜像对我没有任何作用
  • 这种方式相当老套,并且使用付费的第 3 方软件(部分原因是我将其作为评论发布),但如果要使用 BetterTouchTool,则会有一个名为“移动并最大化所有窗口以鼠标显示”,正如它所说的那样!还有一点需要注意的是,这不适用于全屏应用。
  • 经过一些测试并与其他应用程序/工作流程来回反复,更适合我的解决方案是displayplacer。这个免费的开源命令行实用程序允许人们保存他们的监视器配置并恢复它。使用这个可以使用 Automator 或任何其他可以调用命令行来恢复监视器配置的服务。就像 OP 所做的那样,一个人可以设置一个打开屏幕镜像的配置,另一个关闭屏幕镜像,然后创建一个快捷方式/自动化来调用任一配置。

标签: macos multiple-monitors


【解决方案1】:

Cmd+F1 似乎是 Snow Leopard 中的 Mirror Displays 快捷方式。不过,不知道 Lion 等。

只需点按两次,看看会发生什么(-:

对于喜欢将功能键设置为老式方式(而不是亮度/声音控制等)的人,它将是Cmd+Fn+F1

【讨论】:

  • 如果您想从命令行执行此操作,您可以使用can use this 免费开源工具来执行此操作!
  • 我按了一次,它就镜像了,我再按一次,它把所有的窗口都移到了主显示屏上。谢谢!
  • 值得一提的是,对于喜欢以老式方式使用功能键的人来说,它是 Cmd+Fn+F1。
【解决方案2】:

在 Lion 上,您可以使用 fn+Cmd+F1 切换镜像显示(前提是您默认使用媒体控制键)。

这也适用于 Snow Leopard 以及介于两者之间的所有东西,也可能更远。

【讨论】:

  • 在 Mountain Lion 上使用 fn 对我的 MBP 不起作用,但单独使用 Cmd+F1 可以.
【解决方案3】:

您可以单击“显示”首选项窗格中的“收集窗口”按钮。

【讨论】:

  • @Zydeco 仅从 Displays pref 收集窗口。 :-)(至少,在 10.6 上,它无法收集终端窗口。)
  • 哇,这很神奇,虽然我想知道是否可以创建一个快捷方式(而不是多次点击到达那里)
  • 呸,是的,这正是我想要的,但对于我关心的应用程序,不仅仅是显示屏幕!
【解决方案4】:

正如您所说,最好的答案似乎是再次打开和关闭“镜像显示”。之后,主屏幕上的所有窗口都已收集完毕,副屏幕为空。

这有点麻烦,但在 Lion 中没有其他方法对我有用。

【讨论】:

    【解决方案5】:

    这里有一个命令行脚本可以做到这一点:http://zach.in.tu-clausthal.de/software/

    它在“将屏幕外窗口移动到主屏幕”下的页面下方。


    -- Source: http://www.jonathanlaliberte.com/2007/10/19/move-all-windows-to-your-main-screen/
    -- and: http://www.macosxhints.com/article.php?story=2007102012424539
    --
    -- Improvements:
    -- +  code is more efficient and more elegant now
    -- + windows are moved also, if they are "almost" completely off-screen 
    --      (in the orig. version, they would be moved only if they were completely off-screen)
    -- + windows are moved (if they are moved) to their closest position on-screen
    --     (in the orig. version, they would be moved to a "home position" (0,22) )
    -- Gabriel Zachmann, Jan 2008
    
    -- Example list of processes to ignore: {"xGestures"} or {"xGestures", "OtherApp", ...}
    property processesToIgnore : {"Typinator"}
    
    -- Get the size of the Display(s), only useful if there is one display
    -- otherwise it will grab the total size of both displays
    tell application "Finder"
        set _b to bounds of window of desktop
        set screen_width to item 3 of _b
        set screen_height to item 4 of _b
    end tell
    
    tell application "System Events"
        set allProcesses to application processes
        repeat with i from 1 to count allProcesses
            --display dialog (name of (process i)) as string
            if not (processesToIgnore contains ((name of (process i)) as string)) then
                try
                    tell process i
                        repeat with x from 1 to (count windows)
                            set winPos to position of window x
                            set _x to item 1 of winPos
                            set _y to item 2 of winPos
                            set winSize to size of window x
                            set _w to item 1 of winSize
                            set _h to item 2 of winSize
                            --display dialog (name as string) & " - width: " & (_w as string) & " height: " & (_h as string)
                            
                            if (_x + _w < 40 or _y + _h < 50 or _x > screen_width - 40 or _y > screen_height - 40) then
                                
                                if (_x + _w < 40) then set _x to 0
                                if (_y + _h < 50) then set _y to 22
                                if (_x > screen_width - 40) then
                                    set _x to screen_width - _w
                                    if (_x < 0) then set _x to 0
                                end if
                                if (_y > screen_height - 40) then
                                    set _y to screen_height - _h
                                    if (_y < 22) then set _y to 22
                                end if
                                set position of window x to {_x, _y}
                                
                            end if
                        end repeat
                        
                    end tell
                end try
            end if
        end repeat
    end tell
    

    【讨论】:

    【解决方案6】:

    macosxtips.co.uk 有一篇关于使用 AppleScript 执行此操作的文章,macosxhints.com 有另一篇文章。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-06-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多