开发者

Applescript for safari to click downloads

开发者 https://www.devze.com 2023-02-04 12:39 出处:网络
I have been trying to write some applescript that checks to see if the Downloads window is open in Safari and if it is to click and open the last file in the list which is the last file that was downl

I have been trying to write some applescript that checks to see if the Downloads window is open in Safari and if it is to click and open the last file in the list which is the last file that was downloaded but have been having some issues using Accessibility Inspector I get the following :


<AXApplication: "Safari">
 <AXWindow: "Downloads">
  开发者_JAVA技巧<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

I'm not sure how to access the scroll area and list to get at the button.


This works...

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
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号