编辑:我试图从使用AppleScript的Web代理调试应用程序Charles(http://www.charlesproxy.com/)保存会话文件。基本上,我选择“导出”,输入临时名称,然后保存。但是,在单击组合框2(即“格式”区域)后,尝试单击弹出按钮“XML会话文件(.xml)”后,Applescript编辑器会抛出一个错误,指出它找不到它。Charles和AppleScript(在辅助功能检查器中缺失值)
目前我用下面的代码入侵它,但由于某些原因,它只能在Applescript编辑器中工作,有时在Terminal /我的代码中工作,特别是当我在同一时间执行其他操作时。
tell application "Charles"
activate
end tell
tell application "System Events"
tell process "Charles"
tell menu bar 1
click menu bar item "File"
tell menu "File"
click menu item "Export..."
end tell
end tell
tell window "Save"
keystroke "tempCharles"
delay 0.5
click combo box 2
delay 0.5
key code 125 -- down arrow
delay 0.2
key code 125
delay 0.2
key code 125
delay 0.2
key code 125
delay 0.2
keystroke return
delay 0.4
keystroke return
delay 0.4
keystroke return
end tell
end tell
end tell
我想我的代码看起来像这样
tell window "Save"
keystroke "tempCharles.xml"
delay 3
click combo box 2
tell combo box 2
click pop up button "XML Session File (.xml)"
end tell
click button "Save"
end tell
任何黑客是好的了。在发布之前,尝试在终端上运行“osascript”以检查它是否通过AppleScript编辑器工作。