AppleScript多字元素名称 问题

AppleScript多字元素名称 问题,applescript,Applescript,在AppleScript中,我想访问Adium聊天窗口中的所有聊天列表,查找特定的聊天名称,但不起作用: 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

在AppleScript中,我想访问Adium聊天窗口中的所有聊天列表,查找特定的聊天名称,但不起作用:

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
但我在“聊天窗口”的引用中得到了“语法错误:预期行尾,但找到了复数类名”

回答(来自回答和进一步工作) 直接从进程而不是从“系统事件”获取窗口列表可以避免“复数类名”的阻塞:

然而,被称为“系统事件”的窗口(或聊天窗口)的属性与Adium所知的窗口的属性大不相同。我实际做的是在屏幕上定位窗口。通过系统事件窗口,我可以执行以下操作:

set position of tw to {440, 1600}
set size of tw to {993, 578}
    tell application "Adium"
     activate

     repeat with tw in chat windows
      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
。。。但是有一个直接的窗户,它是

set bounds of tw to {440, 1600, 440+993, 1600+578}
正如劳里·兰塔(Lauri Ranta)在评论中或多或少暗示的那样,将“属性tw”撒在周围可以揭示这些差异

其他答案 我还发现

repeat with tw in (chat windows) of process "Adium"

通过“多字元素名称”问题,但不是“windows具有不同属性”问题。

您尝试为此使用系统事件。我假设“Adium”是可编写脚本的,因此您可以直接与应用程序对话(用“AppleScript Editor.app”打开“Adium.app”查看是否是这样)

我不使用Adium,因此我无法判断脚本的其余部分是否正常,但可以肯定的是,它看起来更像这样:

set position of tw to {440, 1600}
set size of tw to {993, 578}
    tell application "Adium"
     activate

     repeat with tw in chat windows
      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

聊天室和聊天窗口元素包含在应用程序元素中:

tell application "Adium"
    properties of chat "nickserv"
    --chat window "nickserv"
end tell

这就克服了语法错误,但给我留下了更深层次的错误。不过,这回答了我提出的问题。谢谢你的反馈。查看Adium的脚本字典,找出适合脚本的语法。你可以在AppleScript编辑器中完成(…)祝你好运!我从一开始就打开了字典。在那个社区,让我大吃一惊的是,Adium返回的“窗口”与系统事件返回的“窗口”不同。菜鸟错误。这超越了语法错误,但给我留下了更深层次的错误。不过,这回答了我提出的问题。