'Click at'返回"System events got an error..." -Applescript



新手到Applescript,对不起,如果它很愚蠢。我一直在尝试编写一个脚本来检查网络是否健康,如果没有,请转到 url 并单击网页上的"登录"按钮(实际上该页面具有我的浏览器自动填充的"用户名"和"密码")。我使用了以下代码;

try
set thePing to do shell script "/sbin/ping -o -c 1 www.google.com"
on error
tell application "Google Chrome" to open location "https://mwcp-ekm-04.adlkerala.com:8001"
delay 5
tell application "System Events"
    tell process "chrome"
        click at {585, 220}
    end tell
end tell
end try

(我知道javascript会比"Click at"更好,但后来我不知道该怎么做)

运行时,我收到以下错误"系统事件出现错误:无法将 {585, 220} 放入类型列表。 从 {585, 220} 到 list 的数字 -1700"

编辑:经过一番谷歌搜索,我设法提取了 Java 代码; try set thePing to do shell script "/sbin/ping -o -c 1 www.google.com" on error tell application "Safari" to open location "https://mwcp-ekm-04.adlkerala.com:8001" delay 3 tell application "Safari" do JavaScript "document.getElementById('submit').click();" in current tab of first window end tell
end try
但现在这返回一个结果"缺失值"

我将不胜感激任何帮助

谢谢

我认为click at在 10.9 中停止工作。或者至少

tell application "System Events" to tell process "Safari"
    set frontmost to true
    click at {20, 20}
end tell

在 10.8 中对我有用,但会导致类似 10.9 中的error "System Events got an error: Can’t make {20, 20} into type list." number -1700 from {20, 20} to list错误。

尝试使用 MouseTools 或 cliclick(或 JavaScript)。

我刚刚回答了一个非常相似的问题,试图"点击桌面"(这里)......

System Events 的 sdef 文件说,当发送到全局坐标中单击的 { x, y } 位置的"进程"对象时,"单击"仍然有效(意思是:在绝对屏幕坐标中,而不是相对于应用程序的窗口)。

所以:你不能"点击"桌面上可见的文件(作为一个"文件",实际上有:进程"Finder"滚动区域的组1的图像),但你仍然可以点击任何窗口/按钮。

屏幕上任何地方的每一次"点击"都必须有一个"目标"。它不会像鼠标指针那样工作。

相关内容

最新更新