从Python运行AppleScript(单击菜单项)

2024-05-29 02:48:08 发布

您现在位置:Python中文网/ 问答频道 /正文

从python(macosx10.7.3)运行applescript时遇到问题。实际上,我可以运行applescript,但是某个部分不起作用。特别是,我正在尝试单击应用程序中的菜单项:

args = ['osascript', '-e', 'tell app "StataMP" to activate']
args.extend(['-e', 'tell application "System Events" to tell application process "StataMP" to click menu item "run tmp file" of menu 1 of menu item "Applescript helpers" of menu 1 of menu bar item "User" of menu bar 1'])
subprocess.Popen(args)

我还尝试了一个更简单的版本来测试脚本,但没有成功:

^{pr2}$

是的,“Enableaccessforassistivedevices”被启用了,我还试着禁用它并再次启用它(没有重新启动)。在

谢谢!在


Tags: oftoapp应用程序applicationbarargsitem

热门问题