'Click at' returns “System events got an error…” -Applescript

不羁的心 提交于 2019-12-10 22:41:02

问题


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

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

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"

EDIT: 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"

i would appreciate any help

Thanks


回答1:


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

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).

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.




回答2:


I think click at stopped working in 10.9. Or at least

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

works for me in 10.8 but results in an error like error "System Events got an error: Can’t make {20, 20} into type list." number -1700 from {20, 20} to list in 10.9.

Try to use MouseTools or cliclick (or JavaScript) instead.



来源:https://stackoverflow.com/questions/22078492/click-at-returns-system-events-got-an-error-applescript

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!