作者mofassfox (狐狸)
看板MAC
标题[软体] 请问哪步错了?
时间Mon Dec 23 21:29:14 2024
简体的时候都没问题,切成繁体就抓不到设定里的显示器
主要是19行一直抓不到,请大大解惑
手机截图请见谅
https://i.imgur.com/1IcBDgB.jpeg
on findLastTargetIndex(targetItem, itemList)
set lastIndex to 0
repeat with i from (count of itemList) to 1 by -1
if item i of itemList is targetItem then
set lastIndex to i
exit repeat
end if
end repeat
return lastIndex
end findLastTargetIndex
beep 1
beep 1
tell application "System Settings"
activate
delay 1
tell application "System Events"
tell process "System Settings"
click menu item "显示器" of menu "显示" of menu bar it
em "显示" of menu bar 1
delay 0.3
tell group 1 of group 2 of splitter group 1 of group 1
of window "显示器"
try
click pop up button "添加"
delay 0.3
-- 获取所有菜单项的名称
set menuItems to name of menu items of
menu "添加" of pop up button "添加"
-- 通过名字查找要准确一些,这里去找最
后一个名字的索引,因为如果 ipadpro 有
妙控键盘,就会出现两个名字,我们需要最后一个名字,第一个名字是连接键鼠的
set targetIndex to (my findLastTargetI
ndex("XXX‘s iPad", menuItems))
-- 点击目标菜单项
click menu item targetIndex of menu "
添加" of pop up button "添加"
on error
delay 0.5
end try
end tell
end tell
end tell
end tell
delay 1
beep 1
tell application "System Settings" to quit
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 111.250.101.58 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/MAC/M.1734960556.A.E1A.html
※ 编辑: mofassfox (111.250.101.58 台湾), 12/23/2024 21:31:57
1F:→ tyf99: 显示 添加 都是支语,你自己要依据Mac介面的用词改掉 12/23 21:41
2F:→ mofassfox: 应该是添加的问题但不知道该换什麽 12/23 21:42
3F:→ mofassfox: 然後显示不对的话我也不知道该换什麽了…… 12/23 21:44
4F:→ tyf99: 你自己看看顶部选单有什麽字 12/23 21:46
5F:→ mofassfox: 指令词汇里找不到类似的…… 12/23 21:51
7F:→ tyf99: 至於按钮什麽的,你要用entire contents去找 12/23 22:10
8F:→ mofassfox: 这样底下要全改,我没有那麽强QQ 12/23 22:16
10F:→ tyf99: 我不知道你那添加的按钮是干啥用的,你可从上面的回传值找 12/23 22:29
11F:→ mofassfox: 这个是用来开机自动抓ipad当萤幕用的,我尝试看看 12/23 22:30
12F:→ mofassfox: 嗯……我不会举一反三QQ 12/23 22:41
13F:→ babylon297: 直接切也是蛮好笑的 你看不出来用语差异很大吗 12/24 03:03
14F:→ mofassfox: 虽然但是,我看设定的确叫显示器啊 12/24 04:28
15F:→ tyf99: 这 Applescript 的写法叫做 GUI scripting 12/24 14:07
16F:→ tyf99: 任一个引用的名称,要跟你萤幕上看到的完全相同才能 match 12/24 14:08
17F:→ tyf99: menu bar是萤幕顶部那条,系统设定没有选单是叫"显示"的 12/24 14:09
18F:→ tyf99: 至於添加的按钮,我已经没有iPad,所以我这边没那颗按钮 12/24 14:29
19F:→ tyf99: 你只能自己去找正确的繁中名称,不然就继续用简体中文介面 12/24 14:30