这是执行此操作的命令行脚本: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