移动所有窗口到第一屏

公司主机有两个显示器,一个是主、一个是扩展,安装了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 @   从雍和宫走到电影学院  阅读(9)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· 单线程的Redis速度为什么快?
· 展开说说关于C#中ORM框架的用法!
· Pantheons:用 TypeScript 打造主流大模型对话的一站式集成库
点击右上角即可分享
微信分享提示