我正在尝试为我的Notes应用添加快捷方式,以便输入上标和下标。下面的脚本没有给出任何错误,并且正确地找到/点击了'上标'子菜单项,但返回到笔记应用程序时,此选项未激活/选中。如果我取消注释它下面的行,那么该功能(打开' Notes帮助')可以完美地运行。
tell application "System Events"
tell process "Notes"
click menu item "Superscript" of menu 1 of menu item "Baseline" of menu 1 of menu item "Font" of menu "Format" of menu bar 1
-- click menu item "Notes Help" of menu "Help" of menu bar 1
end tell
end tell
我做错了什么?
答案 0 :(得分:0)
AppleScript代码通常都是关于个人风格的,但我只是通过探测菜单栏来快速写出来。经过测试和正常工作。
tell application "Notes" to activate -- needed because you say "but when returning to the notes app" meaning you're not there already
-- tell System Events to Click, not tell system events to tell process to click... process doesn't understand click.
tell application "System Events"
click menu item "Superscript" of menu "Baseline" of menu item "Baseline" of menu "Font" of menu item "Font" of menu "Format" of menu bar item "Format" of menu bar 1 of application process "Notes" of application "System Events"
end tell