【发布时间】:2021-11-25 01:39:34
【问题描述】:
我正在使用 LG OnScreen Control 应用程序在使用图片时在菜单项中没有名称的不同显示器布局之间切换。我想写一个applescript,点击第一个或第9个,我最喜欢的选择。 =)
我怎样才能点击它们?我只能用下面的代码来选择它们
ignoring application responses
tell application "System Events" to tell process "OnScreen Control"
click menu bar item 1 of menu bar 2
end tell
end ignoring
delay 0.1
do shell script "killall System\\ Events"
tell application "System Events" to tell process "OnScreen Control"
tell menu bar item 1 of menu bar 2
click menu item "Screen Split" of menu 1
end tell
end tell
UPDATE1:啊,我真傻,我想我可以使用“key code 125”多次单击向下箭头,然后使用“key code 76”回车。
ignoring application responses
tell application "System Events" to tell process "OnScreen Control"
click menu bar item 1 of menu bar 2
end tell
end ignoring
delay 0.1
do shell script "killall System\\ Events"
tell application "System Events" to tell process "OnScreen Control"
tell menu bar item 1 of menu bar 2
click menu item "Screen Split" of menu 1
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 125
key code 76
end tell
end tell
想知道是否有更好更快的方法来执行此操作?尽管没有名称,但直接解决子项目?
UDPATE2感谢@user3439894
ignoring application responses
tell application "System Events" to tell process "OnScreen Control"
click menu bar item 1 of menu bar 2
end tell
end ignoring
delay 0.1
do shell script "killall System\\ Events"
tell application "System Events" to tell process "OnScreen Control"
tell menu bar item 1 of menu bar 2
click menu item "Screen Split" of menu 1
click menu item 9 of menu 1 of menu item "Screen Split" of menu 1
end tell
end tell
【问题讨论】:
-
我真傻,我想我可以使用“密钥代码 76”。想知道是否有更好更快的方法来执行此操作?
标签: macos menu applescript automator