AppleScript单击多个Google Chrome按钮 - 随机停止工作

发布于 2025-01-28 22:45:28 字数 580 浏览 2 评论 0 原文

我正在使用一个相对简单的苹果本来自动单击Google Chrome中的两个按钮。它已经工作了几个星期,但是现在已经随机停止了,而我没有改变任何东西。这是我正在使用的代码:

...

set loc1 to {1200, 400}
set loc2 to {1000, 600}

repeat 30 times
    tell application "System Events"
        tell process "Google Chrome"
            set newest to true
            delay 0.2
            click at loc1
            delay 0.1
            click at loc1
            delay 0.1
            click at loc2
        end tell
    end tell
end repeat

...

进行了一些实验后,我仍然可以单击Chrome浏览器顶部的标签,但是我无法单击网页上的任何按钮/元素。我可以尝试的事情有什么想法吗?

谢谢!

I was using a relatively simple applescript to automate clicking on two buttons in Google Chrome. It was working for weeks but has now stopped randomly without me changing anything. Here is the code I was using:

...

set loc1 to {1200, 400}
set loc2 to {1000, 600}

repeat 30 times
    tell application "System Events"
        tell process "Google Chrome"
            set newest to true
            delay 0.2
            click at loc1
            delay 0.1
            click at loc1
            delay 0.1
            click at loc2
        end tell
    end tell
end repeat

...

After some experimenting I can still click on the tabs at the top of the chrome browser, but I can no longer click on any buttons/elements on the webpage. Any thoughts on things I can try?

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

以往的大感动 2025-02-04 22:45:28

@mrstuckguy ,我看到您的问题还没有答案。我认为只要使用GreaseMonKey风格的用户脚本(JavaScript)与HTML元素进行交互,您可能会更好。检查饼干标语。如果您需要烦人的弹出窗口的帮助,请询问。

您会添加一个类似的用户脚本管理器:

setTimeout(() => {
   var elements = document.querySelectorAll('a-moving-target-button')
   elements.forEach((element) => {
      if (element.textContent == 'I Agree') { element.click() }
   })
},1000)

您应该知道,这些按钮元素的布局分别不断变化并编辑它们。

@mrstuckguy, I see your question has no answer yet. I think you'd probably be better off just using Greasemonkey-style user scripts (JavaScript) to interact with HTML elements. Check Tampermonkey for example. You have a lot of examples on the web of how to interact with HTML buttons such as those pesky Cookie Banners. If you need help with an annoying popup just ask.

You'd add in a user scripts manager something like this:

setTimeout(() => {
   var elements = document.querySelectorAll('a-moving-target-button')
   elements.forEach((element) => {
      if (element.textContent == 'I Agree') { element.click() }
   })
},1000)

You should be aware, however, that the layout of these button-elements keeps changing and redact them respectively.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文