从Applescript设置弹出按钮的值

时间:2019-07-15 16:12:43

标签: applescript

我正在尝试使用applescript设置外部应用程序设置。我目前有

tell application "System Events"
     tell process "Pro Tools"
         click menu item "Save Copy In..." of menu "File" of menu bar 1
         tell pop up button 4 of window "Save Copy In..."
             click
             set value to "AIFF"
         end tell
      end tell
 end tell

但是在set value点什么也没有发生。任何帮助将不胜感激!附件是我被困的地方的屏幕截图。

enter image description here

2 个答案:

答案 0 :(得分:0)

尝试插入一小段延迟以确保菜单可用,而不是将value pick设置为menu item

tell application "System Events"
     tell process "Pro Tools"
         click menu item "Save Copy In..." of menu "File" of menu bar 1
         tell pop up button 4 of window "Save Copy In..."
             click
             delay 0.2
             pick menu item "AIFF" of menu 1
         end tell
      end tell
 end tell

未记录命令pick,它是click的同义词。

答案 1 :(得分:0)

我认为您只需要等待直到“保存副本...”窗口出现即可。试试这个代码,它会添加一个寻找窗口的延迟循环。

tell application "System Events"
    tell process "Pro Tools"
        tell menu bar 1's menu "File"
            click menu item "Save Copy In..."
        end tell

        repeat until (exists window "Save Copy In...")
            delay 0.1
        end repeat

        tell window "Save Copy In..."'s pop up button 4
            click
            -- the menu does not appear inthe PUB's view heirarchy until after it's clicked
            tell menu 1
                click menu item "AIFF" -- 'pick' should work too
            end tell
        end tell
    end tell
end tell