Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

Applescript Editor Coding Question

I am in the midst of creating a code for Applescript Editor. The goal of this script is to repeatedly click on a given part of the screen in 2 second time intervals - for example, to click "Refresh Page" every 2 seconds repeatedly. Currently I have:


set x to 280

set y to 545

set l to 500

repeat 100 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 & ");

END"

end repeat

^ What I want to do is shorten the time between clicks. As I have it right now I'm just repeating the shell script process over and over again, and thus the time between clicks is about 4 seconds. How would I shorten this period of time to 2 seconds?

Posted on Feb 9, 2016 11:53 AM

Reply
1 reply

Applescript Editor Coding Question

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.