作者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/m.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