用于徒步旅行的Applescript点击下载

时间:2011-01-10 17:11:08

标签: events safari keyboard applescript

我一直在尝试编写一些AppleScript来检查下载窗口是否在Safari中打开,是否要点击并打开列表中的最后一个文件,该文件是下载的最后一个文件但是已经有了一些文件使用辅助功能检查器的问题我得到以下内容:


<AXApplication: "Safari">
 <AXWindow: "Downloads">
  <AXScrollArea>
   <AXList>
    <AXGroup: "ExcelTest.xls">
     <AXButton: "file icon">
Attributes:
   AXRole:  "AXButton"
   AXRoleDescription:  "button"
   AXHelp:  "Open"
   AXFocused:  "false"
   AXParent:  ""
   AXWindow:  ""
   AXTopLevelUIElement:  ""
   AXPosition:  "x=1062 y=396"
   AXSize:  "w=32 h=32"
   AXDescription:  "file icon"`
   AXEnabled:  "true"
Actions:
      AXPress - press

我不知道如何访问滚动区域和列表以获取按钮。

1 个答案:

答案 0 :(得分:1)

这有效......

set downloadsIsFrontmost to false
tell application "Safari"
    set theWindows to name of windows
    if (item 1 of theWindows) is "Downloads" then
        activate
        set downloadsIsFrontmost to true
    end if
end tell

if downloadsIsFrontmost then
    tell application "System Events"
        tell process "Safari"
            set theGroups to groups of list 1 of scroll area 1 of window "Downloads"
            set lastGroup to last item of theGroups
            repeat 2 times
                click button 1 of lastGroup
                delay 0.05
            end repeat
        end tell
    end tell
end if