【发布时间】:2017-04-10 20:50:29
【问题描述】:
我正在尝试使用 AppleScript 在 Adobe Acrobat Pro 中打开 PDF,并在保存文件时使用“减小文件大小”选项减小文件大小。
根据 Accessibility Inspector 的说法,它具有以下层次结构: Accessibility Inspector Image
我的第一步是使用set allElem to entire contents of window "Save As PDF" 跟踪窗口中的所有元素。输出表明该元素不是按钮或复选框:
group "Reduce File Size" of group " My Computer " of UI element 1 of group 1 of group 1 of window "Save As PDF" of application process "AdobeAcrobat" of application "System Events"
static text "Reduce File Size" of group 1 of group "Reduce File Size" of group " My Computer " of UI element 1 of group 1 of group 1 of window "Save As PDF" of application process "AdobeAcrobat" of application "System Events"
text field 1 of static text "Reduce File Size" of group 1 of group "Reduce File Size" of group " My Computer " of UI element 1 of group 1 of group 1 of window "Save As PDF" of application process "AdobeAcrobat" of application "System Events"
group 1 of group "Reduce File Size" of group " My Computer " of UI element 1 of group 1 of group 1 of window "Save As PDF" of application process "AdobeAcrobat" of application "System Events"
没有点击按钮,我尝试通过向窗口发送击键来解决这个问题。
tell window "Save As PDF"
activate
keystroke tab
keystroke tab
keystroke tab
keystroke tab
delay 1
key code 36 --return key
end tell
但是“另存为 PDF”窗口似乎没有出现在前面;因此,击键不会注册到该特定窗口。
同样
tell group "Reduce File Size" of group " My Computer " of UI element 1 of group 1 of group 1 of window "Save As PDF" of application process "AdobeAcrobat" of application "System Events"
set {xPosition, yPosition} to position
set {xSize, ySize} to size
click at {xPosition + (xSize div 2), yPosition + (ySize div 2)}
end tell
不起作用,因为由于某种原因,“另存为 PDF”窗口中没有发生单击事件。
所以现在我想知道两件事:
实际上是否有我可以单击的按钮或复选框(我是否以某种方式遗漏了可用单击事件的某些内容,例如,您可以将单击事件发送到静态文本吗?)。
为什么按键和点击事件没有在窗口中注册?
【问题讨论】:
标签: applescript acrobat