Wil*_*son 19 macos multiple-monitors
每当我将MacBook从桌面上移开然后将其插入外部显示器(作为主要显示器)时,我就会进入笔记本电脑显示器和外部显示器中存放窗口的状态.
要将所有窗口移动到单个屏幕,我当前的解决方案是在显示首选项中"打开镜像",然后再将其关闭.但这是相当繁琐的.有谁知道更好的方法?
我担心@ erlando发布的脚本对我来说绝对没有任何意义,运行Mac OS X 10.5.4.(即,在两个屏幕上都有窗口,运行脚本不会移动它们中的任何一个,并且它不会返回任何错误.)我想我必须坚持使用上面提到的"镜像/取消镜像"方法.
@ Denton:我担心这些链接提供脚本,可以将从任何屏幕上孤立的窗口重新放回到显示器上.我只是想将所有窗口从辅助显示器移动到主显示器上.
这是一个执行此操作的命令行脚本: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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29726 次 |
| 最近记录: |