问题
从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