如何将对象格式的Applescript输出解析为文本?

如何将对象格式的Applescript输出解析为文本?,applescript,Applescript,目前我正在运行从Java中的Applescript检索窗口的全部内容,Applescript正在返回类对象,如果我从Java中运行相同的脚本,则不会发生这种情况,请建议如何格式化相同的脚本 tell application "System Events" tell process "Install Adobe Flash Player" set tElements to entire contents of window 1 end tell end t

目前我正在运行从Java中的Applescript检索窗口的全部内容,Applescript正在返回类对象,如果我从Java中运行相同的脚本,则不会发生这种情况,请建议如何格式化相同的脚本

tell application "System Events"

    tell process "Install Adobe Flash Player"

      set tElements to entire contents of window 1

        end tell
end tell
tElements
输出:

{button 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", button 2 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", button 3 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", group 1 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", image 1 of group 1 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", group 2 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", static text "Adobe Flash Player 11" of group 2 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", progress indicator 1 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", group 3 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", static text "  " of group 3 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", image 1 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", group 4 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", static text "Error: General installation error" of group 4 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", button "Finish" of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events", static text "Adobe Flash Player Installer" of window "Adobe Flash Player Installer" of application process "Install Adobe Flash Player" of application "System Events"}

你想瞄准其中一个。。。哪一个?你别说但是,通常情况下,您会获得其中一个对象的“值”。例如,你会做这样的事情

tell application "System Events"
    tell process "Install Adobe Flash Player"
       set theValue to value of group 2 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer"
    end tell
end tell
如果“值”不起作用,那么您可以获取对象的属性,并查看您想要的属性

tell application "System Events"
        tell process "Install Adobe Flash Player"
           set theProperties to properties of group 2 of UI element 1 of scroll area 1 of window "Adobe Flash Player Installer"
        end tell
end tell

感谢您的回复,我不想在这里硬编码,如组2、UI元素等。因此,这就是我用Java解析整个窗口内容输出的原因。。