电脑横屏了怎么旋转过来快捷键,台式电脑横屏了怎么旋转过来快捷键

前言

一个程序猿么,在用不同系统的时候,显示器的屏幕状态会切换的,比如用Mac在看文档或者撸代码时用竖屏,用Win打游戏时用横屏

其实手动旋转屏幕倒是其次,但是有时候在横屏状态下突然打开Mac就有些麻木了。手动设置一两次便不说什么了,但是博主多次设置后着实觉得有点儿麻烦!所以找了一下脚本。

参考的脚本是有多个显示器的话,需要遍历去修改。

我这里提供一个单显示器的脚本来切换。

系统环境:Monterey 12.4

脚本代码

首先,打开脚本编辑器.app这个应用。

输入脚本内容:

(*
Now works with Monterey 12.4
Rotate Display on machines, support toggling between only two modes - landscape and portrait
NOTE: UI Scripting must be enabled for this to work!  Confirm that
"Enable access for assistive devices" is checked in the 
Universal Access System Preference Pane
*)
(*
v1.2.2022-12-15 updated to work on Monterey 12.4.  Thanks, Keen
v1.2.2013-01-26 Thanks, Rich Graham for pointing out that display panels may have different layouts.  "button 1" below might need to change to "button 2" (or 3).
v1.1.2012-09-02 updated to work on 10.8 Mountain Lion.  Thanks, F. Parsons
v1.1.2010-08-01 updated to work with 10.6.4's reverted(?) display panel
v1.1.2010-04-08 updated to work with 10.6.3's revised display panel
v1.1.2006-03-01 updated to handle displays with the same name.
v1.1.2006-05-28-Bryan updated to handle displays with the same name.
v1.1.2009-08-02 - Bryan updated to work with Snow Leopard
*)
-- 打开系统偏好设置中的显示器
tell application "System Preferences"
 activate
 set current pane to pane "com.apple.preference.displays"
end tell
delay 3
my setDisplay(1)
on setDisplay(thisDisplay)
 set rotatable to false
 tell application "System Events"
  tell process "System Preferences"
   tell window thisDisplay
    tell group 1
     try
      click pop up button 3
      tell pop up button 3
       repeat with 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 now, switch to portrait mode
        set rotateMenuItem to 4
       else
        -- is not landscape now, switch 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 laptop's built in display."
     end try
    end tell
   end tell
   
   delay 5
   if rotatable then
    --  等切换完成五秒之后,确认窗口
    try
     tell window 1
      tell sheet 1
       click button "确认"
       log "success"
      end tell
     end tell
    on error errText
     log errText
     delay 1
    end try
   end if
   
   quit
  end tell
 end tell
end setDisplay

保存成为App文件即可。

注意运行的时候需要打开辅助功能选项。

感谢

用Alfred实现Mac OSX快捷旋转屏幕

Alfred 快捷切换MacBook外接显示器横竖屏

创业项目群,学习操作 18个小项目,添加 微信:923199819  备注:小项目

本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 zoodoho@qq.com举报,一经查实,本站将立刻删除。
如若转载,请注明出处:https://www.zodoho.com/110685.html