“点击"返回“系统事件出错..."; -Applescript [英] 'Click at' returns "System events got an error..." -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会比单击"Click at"更好,但后来我不知道该怎么做)
(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代码;
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
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
but now this returns a result "Missing Values"
end try
我将不胜感激
谢谢
推荐答案
我刚刚回答了s.o一个非常相似的问题.尝试单击桌面"(此处)...
I just answered a quite similar problem with s.o. trying to "click at desktop" (here) ...
System Events的sdef文件说,点击"在发送到流程"对象 [在{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组的图像),但您仍然可以点击任意窗口/按钮.
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屋!