@RazOrEdge @Slydude
Update:
I have managed to get FF to work with this, so I've given up on Safari so the above problem is not longer an issue. I have removed these lines:
delay 1
key code 55 using { command down }
And it is running fine. Thank you so much for trying to find a fix for me.
Now I want to click in two different places. I pulled the edges of the window until they touched the bottom of the menu bar and all the edges, so that everything is always is the same place, and I found the location of the two things I want clicked.
My original concept for modification was this:
on idle
delay (random number from 1 to 5)
tell application "System Events"
(tell the mouse to move to specific coordinates here)
key code 87
delay 15
(tell the mouse to move to specific coordinates here)
key code 87
delay 15
end tell
return 10
end idle
but there just doesn't seem so be a simple way to tell the cursor where to move to. *sigh*
I thought I would be able to do this on my own. I mean, really, I'm not trying to do something very complicated. I've spent 2 days trying to figure out how to move the mouse to those two locations, but searches brought up only very complicated scripts, scripts nested inside other scripts, or scrips requiring a combination of scripting languages. Is it really so difficult to just move the mouse/cursor?
This is an example:
set x to 30
set y to 5
set l to 50 -- click same location 50 times
do shell script "
/usr/bin/python <<END
import sys
import time
from Quartz.CoreGraphics import *
def mouseEvent(type, posx, posy):
theEvent = CGEventCreateMouseEvent(None, type, (posx,posy), kCGMouseButtonLeft)
CGEventPost(kCGHIDEventTap, theEvent)
def mousemove(posx,posy):
mouseEvent(kCGEventMouseMoved, posx,posy);
def mouseclick(posx,posy):
mouseEvent(kCGEventLeftMouseDown, posx,posy);
mouseEvent(kCGEventLeftMouseUp, posx,posy);
ourEvent = CGEventCreate(None);
currentpos=CGEventGetLocation(ourEvent); # Save current mouse position
for x in range(0, " & l & "):
mouseclick(" & x & "," & y & ");
mousemove(int(currentpos.x),int(currentpos.y)); # Restore mouse position
END"
Below is the most simple one I found:
tell application "Safari"
activate
end tell
repeat with i from 1 to 10
delay 5
tell application "System Events"
tell process "Safari"
click at {46, 239}
end tell
end tell
end repeat
Additionally, all of my experiments have been refused by Accessibility, which I had to use to run the original script. I tried to add it to the permissions, and it ignored me. (And now I can't seem to find that window) I thought I would be very clever and just edit my ideas into the script that is already there, but anything involving locations gives me a notice that it isn't allowed or some such thing.
Help? It is really so complicated. I am just looking for a simple way to do a simple thing.
Do I need Applescript Toolbox for this?