移动所有窗口到第一屏

公司主机有两个显示器,一个是主、一个是扩展,安装了todesk方便在家应急登陆。可有的时候回家登陆发现todesk免费版本只能看到主屏内容,我拉到第二屏的的窗口比如chrome、sublime这些看不到,该脚本就是解决这个问题,适用于所有远程桌面的用户。

tell application "System Events"
	-- 要排除的应用程序名称
	set appNames to {"iTerm2"}
	
	-- 获取所有活动的窗口
	set allProcesses to (every process whose visible is true)
	
	repeat with appProcess in allProcesses
		try
			set appName to name of appProcess
			
			-- 打印日志输出当前的 appName
			log "Checking app: " & appName
			-- 判断 appName 是否在排除列表中
			if appName is not in appNames then
				-- 获取当前进程的窗口列表
				tell appProcess
					set windowList to every window
					repeat with aWindow in windowList
						-- 移动窗口到 (0, 0)
						set position of aWindow to {0, 0}
					end repeat
				end tell
			end if
		on error errMsg
			-- 处理出错情况
		end try
	end repeat
end tell
posted @ 2024-11-15 09:58  从雍和宫走到电影学院  阅读(29)  评论(0)    收藏  举报