Applescript:点击位置不起作用


1

截图

我正在尝试单击Chrome扩展程序(Google突出显示:https : //chrome.google.com/webstore/detail/multi-highlight/pfgfgjlejbbpfmcfjhdmikihihddeeji),然后在文本框上单击并覆盖我的变量。

这是我的代码

set NoteforGoogleCHrome to "My text should be there"

tell application "Google Chrome"
    activate
end tell
tell application "System Events"
    tell process "Google Chrome"

        delay 2
        click button 8 of toolbar 2 of window "myTab" of application process "Google Chrome" of application "System Events"
        delay 0.2
        keystroke tab
        delay 0.2
        keystroke NoteforGoogleCHrome
        delay 0.2
        keystroke space
    end tell
end tell

我试过了,但这在大多数情况下都是失败的。

当我尝试单击文本字段时(单击2),我总是遇到错误:

在{4000,114}处单击过程“ Google Chrome”->缺少值

但是,如果我对“点击1”执行相同操作,则不会出错。

你能给我一些建议吗?

Answers:


3

以下内容适用于macOS High Sierra 10.13.5和Google Chrome 67.0.3396.99。

示例AppleScript 代码

set NoteforGoogleCHrome to "click me"

tell application "Google Chrome" to activate
delay 0.5
tell application "System Events"
    click (every UI element of toolbar 2 of front window of application process "Chrome" whose help is "Multi-highlight")
    delay 1
    key code 48 -- # Tab Key
    delay 0.2
    keystroke NoteforGoogleCHrome & space
end tell

如您在下图中所看到的,它突出显示了click和的所有出现me

在此处输入图片说明


谢谢您的回复。明天早上我会尝试的,但这很有道理。
凯文(Kevin)
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.