电脑变成横屏怎么办
奇闻异事 2023-10-30 05:29www.178767.com奇闻异事
前言
一个程序猿么,在用不同系统的时候,显示器的屏幕状态会切换的,比如用
Mac
Win
其实手动旋转屏幕倒是,有时候在横屏状态下突然打开
Mac
参考的脚本是有多个显示器的话,需要遍历去修改。
我这里提供一个单显示器的脚本来切换。
系统环境Monterey 12.4
脚本代码
,打开
脚本编辑器.app
输入脚本内容
(No orks ith Monterey 12.4Rotate Display on machines, support toggling beteen only to modes - landscape and portraitNOTE: UI Scripting must be enabled for this to ork! Confirm that"Enable aess for assistive devices" is checked in the Universal Aess System Preference Pane)(v1.2.2022-12-15 updated to ork on Monterey 12.4. Thanks, Keenv1.2.2013-01-26 Thanks, Rich Graham for pointing out that display panels may have different layouts. "button 1" belo might need to change to "button 2" (or 3).v1.1.2012-09-02 updated to ork on 10.8 Mountain Lion. Thanks, F. Parsonsv1.1.2010-08-01 updated to ork ith 10.6.4's reverted(?) display panelv1.1.2010-04-08 updated to ork ith 10.6.3's revised display panelv1.1.2006-03-01 updated to handle displays ith the same name.v1.1.2006-05-28-Bryan updated to handle displays ith the same name.v1.1.2009-08-02 - Bryan updated to ork ith Sno Leopard)-- 打开系统偏好设置中的显示器tell application "System Preferences" activate set current pane to pane ".apple.preference.displays"end telldelay 3my setDisplay(1)on setDisplay(thisDisplay) set rotatable to false tell application "System Events" tell process "System Preferences" tell indo thisDisplay tell group 1 try click pop up button 3 tell pop up button 3 repeat ith i from 1 to 4 if selected of menu item i of menu 1 is true then exit repeat end if end repeat log i -- 标准水平就是1,90度是2,180度是3,270度是4 -- 我的逻辑是在标准水平和垂直之间进行切换 if i is equal to 1 then -- is landscape no, sitch to portrait mode set rotateMenuItem to 4 else -- is not landscape no, sitch to landscape set rotateMenuItem to 1 end if click menu item rotateMenuItem of menu 1 end tell -- If "Standard" is selected, no confirmation dialog is displayed. if rotateMenuItem is not 1 then set rotatable to true end if on error log "Can't rotate display. It may be the lap's built in display." end try end tell end tell delay 5 if rotatable then -- 等切换完成五秒之后,确认窗口 try tell indo 1 tell sheet 1 click button "确认" log "suess" end tell end tell on error errText log errText delay 1 end try end if quit end tell end tellend setDisplay
保存成为App文件即可。
注意运行的时候需要打开辅助功能选项。
感谢
用Alfred实现Mac OSX快捷旋转屏幕
Alfred 快捷切换MacBook外接显示器横竖屏