Lentin
V2EX  ›  macOS

由于 macOS 上 iPhone 镜像功能无法利用第三方软件切换滚轮方向,我写了个脚本来切换

  •  
  •   Lentin · 4h 45m ago · 283 views

    用了 Mos 并不能实现在”iPhone 镜像“的反转滚轮方向用着很别扭,跟 Gemini 聊了一会写了个脚本
    格式为 AppleScript ,可以直接用这个快捷指令用聚焦来唤起执行,切换就很方便了
    https://www.icloud.com/shortcuts/fff70a282668481da502b81461437c4d
    ⚠️记得在隐私与安全-辅助功能-给“聚焦”和“快捷指令”赋予权限
    如果你有其他工具来切换的话可以直接用下面的代码执行脚本,问了 AI 听说可以利用 Hammerspoon 检测鼠标拔插事件来自动执行,我还是更喜欢手动执行,可以自行研究下。

    do shell script "open 'x-apple.systempreferences:com.apple.Mouse-Settings.extension'"
    
    tell application "System Events"
    	tell process "System Settings"
    		set maxWaitTime to 30
    		set retryCount to 0
    		set isClicked to false
    		
    		repeat until isClicked or retryCount > maxWaitTime
    			try
    				click checkbox "自然滚动" of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
    				set isClicked to true
    			on error
    				delay 0.1
    				set retryCount to retryCount + 1
    			end try
    		end repeat
    		
    	end tell
    end tell
    
    quit application "System Settings"
    

    PS:不知道为什么 Apple 连鼠标和触控板两个地方的滚轮方向单独切换都做不到,实在是蠢透了。。。

    Supplement 1  ·  2h 6m ago

    修改了一下脚本,上面的脚本拔掉鼠标就不行了 快捷指令链接:https://www.icloud.com/shortcuts/af1bcf7d5e2b48a4839e7051a9a26fd3

    do shell script "open 'x-apple.systempreferences:com.apple.Trackpad-Settings.extension'"
    tell application "System Events"
    	set frontmost of process "System Settings" to true
    	tell process "System Settings"
    		set waitCount to 0
    		repeat until exists radio button 2 of tab group 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
    			delay 0.05
    			set waitCount to waitCount + 1
    			if waitCount > 40 then exit repeat
    		end repeat
    		try
    			click radio button 2 of tab group 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
    			click checkbox 1 of group 1 of scroll area 1 of group 1 of group 3 of splitter group 1 of group 1 of window 1
    		end try
    		
    	end tell
    end tell
    quit application "System Settings"
    
    6 replies    2026-06-05 20:30:56 +08:00
    Chicagoake
        1
    Chicagoake  
       4h 24m ago
    我现在只在有触控板的机器上用镜像,用鼠标的机器点都不点开。
    Lentin
        2
    Lentin  
    OP
       4h 20m ago
    @Chicagoake 嘛,总有鼠标跟触控板来回切换的兄弟,方便一点是一点
    maemolee
        3
    maemolee  
       2h 31m ago
    关于 PS:有一些第三方软件专门管这个的。我之前用过 Mouse Magic ,现在在用 Scroll Reverser ,都是支持分别配置鼠标滚轮和双指触摸滑动方向
    Lentin
        4
    Lentin  
    OP
       2h 29m ago
    @maemolee 建议你看一眼标题,这种第三方软件并不能在 iPhone 镜像应用中生效,必须要设置里开关才可以,这才是我 PS 的原因。。
    1101x1
        5
    1101x1  
       1h 18m ago
    不能置顶 用个鬼 :)
    1101x1
        6
    1101x1  
       1h 16m ago
    苹果傻逼逼的事还干的少吗?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2825 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 13:47 · PVG 21:47 · LAX 06:47 · JFK 09:47
    ♥ Do have faith in what you're doing.