Mac 上 Apple Script 模拟点击的问题
因为工作中有用到Google Authentication,目前Safari上没有相应的插件支持,所以准备通过apple script + alfred workflow的方式来快速复制校验码到剪贴板,所以有如下代码:
tell application "System Events"
if not (exists process "G2FA") then
tell application "G2FA" to activate
end if
log "应用已经打开了~~~"
tell process "G2FA"
tell window 1
click button 2
end tell
end tell
end tell
主要实现:
1、如果G2FA(来自AppStore)没打开,先打开APP
2、打到窗口中的第二个按钮,并点击(在APP中手动点击第二个按钮,会复制校验码到剪贴板)
上面代码执行没有报错,但是没有实现复制检验码的效果,请问下是元素定位错了还是什么问题呢?
附上一个界面图片:
[经过版主编辑]
MacBook Pro 13″, macOS 14.1