Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

yeeehaw

macrumors newbie
Original poster
Jun 29, 2012
6
0
I have a game where I want to press, "3, 2, 1, left click" and keep looping that. How would I go about doing that? Thanks.
 
Last edited:
By using a program called Automator.

It comes pre-installed with your Mac, so check in your Launchpad/Applications folder. You can easily search the forums/Google for tutorials on how to use Automator to complete tasks which require a loop.
 
You could probably use Automator to create a script for what you want to do.

Thanks, I tried that but I don't know how to write the apple scripts. I gave it my best attempt with this:
tell application "Torchlight"
repeat
keystroke "3"
keystroke "2"
keystroke "1"
end repeat
end tell

but it gave me an error and didn't work. Also, I don't know how to tell it to left click.
 
Try this :

Code:
GUI()
--do stuff with UI scripting
-- Activate the application you'd like to target
tell application "Torchlight" to activate
tell application "System Events"
	-- Send your keystroke
	tell process "Torchlight"
		repeat
			keystroke "3"
			keystroke "2"
			keystroke "1"
			click
		end repeat
	end tell
end tell

on GUI()
	tell application "System Events"
		if UI elements enabled then
		else
			repeat until UI elements enabled is true
				beep
				tell application "System Preferences"
					activate
					set current pane to pane "com.apple.preference.universalaccess"
				end tell
				tell application "Finder"
					activate
					display dialog "UI element scripting is not enabled. Please check \"Enable access for assistive devices\"  Then click \"ok\""
				end tell
			end repeat
		end if
	end tell
end GUI

repeat (forever)
Repeats a statement (or statements) until an exit statement is encountered.

Important: A repeat (forever) statement will never complete unless you cause it to do so.
To terminate a repeat (forever) statement, you can:

Use an exit statement and design the logic so that it eventually encounters the exit statement.
Use a “return” statement, which exits the handler or script that contains the loop, and therefore the loop as well.
Use a try statement and rely on an error condition to exit the loop.

Info : https://developer.apple.com/library/mac/#documentation/applescript/conceptual/applescriptlangguide/reference/ASLR_control_statements.html#//apple_ref/doc/uid/TP40000983-CH6g-127362
 
Last edited:
Hello,

So what can I do to make it loop every 0.1 seconds for just 7 minutes? And how exactly can I make it stop? Thank you!
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.