Use AppleScript to automatically click on screen for testing

From Ittichai Chammavanijakul's Wiki
Jump to navigation Jump to search

A simple AppleScript that allows you to run AppleScript engine to automatically click anywhere on screen. It is cool for testing or task automation.

You can find the location of the screen by using the Apple's screen capture (from Command + Control + Shift + 4).

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

There are many other samples if you google for it.