我有一个名为 Fen\xc3\xaatre 的应用程序,当使用命令查看进程名称时,top它给出了名称Fene?~Btre H。
我想单击其菜单栏项下名为“a.py”的项目,如图所示。
\n\n\n\n我的尝试:
\n\ntell application "System Events" to tell process "Fen\xc3\xaatre"\n    tell menu bar item 1 of menu bar 1\n        click\n        click menu item "Show all" of menu 1\n    end tell\nend tell\n错误:
\n\n$ osascript a.applescript \na.applescript:121:157: execution error: System Events got an error: Can\xe2\x80\x99t get menu item "Show all" of menu 1 of menu bar item 1 of menu bar 1 of process "Fen\xc3\xaatre". (-1728)\n请注意,当我仅运行 attemp1 的第一行和最后一行时,它运行良好,当我添加中间行时,它无法运行。
\n\nignoring application responses\n    tell application "System Events" to tell process "Fen\xc3\xaatre"\n        click menu bar item 1 of menu bar 2\n    end tell\nend ignoring\ndo shell script "killall System\\\\ Events"\ndelay 0.1\ntell application "System Events" to tell process "Fen\xc3\xaatre"\n    tell menu bar item 1 of menu bar 2\n        click menu item "a.py" of menu 1\n        -- click menu item 1 of menu 1 -- another try\n    end tell\nend tell\ntell application "System Events" to tell process "Fen\xc3\xaatre"\n    get entire contents of menu bar 2\nend tell\n这给出:
\n\n{menu bar item 1 of menu bar 2 of application process "Fen\xc3\xaatre" of application "System Events"}\n参考文献:
\n Applescript:通过 gui 脚本单击菜单栏项目
\n applescript 单击菜单栏选项
\n https://superuser.com/questions/587815/can-applescript-osascript-be-used-to-click-menu -extra-menu-items
 \n Applescript 显示 Apple 菜单栏项目
\n AppleScript UI 脚本总体来说是否非常慢,或者是我的脚本,还是其他什么?
\n使用 AppleScript 单击应用程序菜单栏项目  
多谢。
\n使用包标识符而不是应用程序名称:
tell application "System Events"
    tell (first application process whose bundle identifier is "BUNDLE_IDENTIFIER_HERE")
        tell menu bar item 1 of menu bar 1
            click
            click menu item "Show all" of menu 1
        end tell
    end tell
end tell
| 归档时间: | 
 | 
| 查看次数: | 3744 次 | 
| 最近记录: |