“点击"返回“系统事件出错...";-Applescript [英] 'Click at' returns "System events got an error..." -Applescript

查看:23
本文介绍了“点击"返回“系统事件出错...";-Applescript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

Newbie to applescript, sorry if its dumb. I have been trying to write a script to check if the network is healthy, if not go to a url and click Login button on the webpage (actually the page has 'username' and 'password' which my browser autofills). i used the following code;

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 会比点击"更好,但后来我不知道该怎么做)

(I know a javascript would have been better that the 'Click at' but then i didnt know how to do that)

运行时出现以下错误系统事件出错:无法将 {585, 220} 放入类型列表."从 {585, 220} 到列表的编号 -1700"

While running i get the following error "System Events got an error: Can’t make {585, 220} into type list." number -1700 from {585, 220} to list"

经过一番谷歌搜索后,我设法提取了 java 代码;<代码>尝试将 Ping 设置为执行 shell 脚本/sbin/ping -o -c 1 www.google.com"出错时告诉应用程序Safari"打开位置https://mwcp-ekm-04.adlkerala.com:8001"延迟 3告诉应用程序Safari"做 JavaScript "document.getElementById('submit').click();"在第一个窗口的当前选项卡中结束告诉
结束尝试但现在这会返回结果缺失值"

after some googling i managed to pull out the java code; 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
but now this returns a result "Missing Values"

我将不胜感激

谢谢

推荐答案

我刚刚回答了一个与 s.o. 非常相似的问题.尝试点击桌面"(此处)...

I just answered a quite similar problem with s.o. trying to "click at desktop" (here) ...

系统事件的 sdef 文件说,点击"仍然有效当发送到进程"对象时 [at] {x, y } 位置,点击,在全局坐标中(意思是:在绝对屏幕坐标中,NOT 相对于应用程序的窗口).

System Events' sdef file says, that "click at" still works when sent to a "process" object [at] the { x, y } location at which to click, in global coordinates (meaning: in absolute screen coordinates, NOT relative to an app's window).

因此:您不能单击"桌面上可见的文件(作为文件"实际上有:进程Finder"滚动区域第 1 组的图像em>) 但您仍然可以单击任何窗口/按钮.

So: you cannot "click at" a file visible on desktop (as a "file" there actually is: image of group 1 of scroll area of process "Finder") but you still can click at any window / button.

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

Every "click", anywhere on your screen must have an "aim". It won't work like a mouse pointer.

这篇关于“点击"返回“系统事件出错...";-Applescript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆