問題
從AppleScript的,我要訪問的所有聊天記錄的列表中的Adium的聊天窗口,尋找一個特定的聊天的名字,但它不工作:的AppleScript多字元素名稱
Adium的詞典包括: [S]的Adium> [C]應用> [E]聊天窗口
我覺得我想要做的就是
tell application "System Events"
tell application "Adium" to activate
repeat with tw in chat windows of process "Adium"
repeat with ch in chats of tw
if name of ch is "nickserv" then
-- do some stuff
end if
end repeat
end repeat
end tell
,但我得到「語法爾ror:期望行結束,但在「聊天窗口」的引用處找到複數類名「。
答案(由響應,並進一步開展工作)
直接從過程獲取窗口列表,而不是從「系統事件」避免在「複數的類名是」節流:
tell application "System Events"
repeat with tw in chat windows of process "Adium"
-- is a syntax error: you're not getting an Adium window, it's a SysEvents window
tell application "Adium"
repeat with tw in chat windows
-- works
然而,「系統事件」已知的窗口(或聊天窗口)的屬性與Adium已知的窗口的屬性非常不同。我實際上做的是將窗口定位在屏幕上。與系統事件窗口,我做這樣的事情:
set position of tw to {440, 1600}
set size of tw to {993, 578}
...但與直接Adium的窗口,它的
set bounds of tw to {440, 1600, 440+993, 1600+578}
灑水「屬性TW」有關,如或多或少暗示Lauri Ranta的評論揭示了這些差異。
對方的回答
我還發現,
repeat with tw in (chat windows) of process "Adium"
不會越過「多字元素名稱」的問題,雖然不是「窗口具有不同的性質」之一。
這會超過語法錯誤,但會給我留下更深的錯誤。不過,這回答了我提出的問題。 – jackr
感謝您的反饋。查看Adium的腳本字典以找出適合您腳本的語法。你可以在AppleScript-Editor中做到這一點(...)祝你好運! – 2013-06-07 14:15:35
我有Adium字典從第一個打開。在這個社區裏,讓我感到沮喪的是,Adium返回的「窗口」與系統事件返回的「窗口」不同。菜鳥錯誤。 – jackr