Reputation: 23
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
but now this returns a result "Missing Values"
end try
i would appreciate any help
Thanks
Upvotes: 2
Views: 3785
Reputation: 440
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.
Upvotes: 0
Reputation: 27613
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.
Upvotes: 3