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

Poff

macrumors 65816
Original poster
Sep 16, 2003
1,258
1
Stavanger, Norway
I have this game where I sometimes go to the market and try to sell things. Is it possible to write an applescript, or get a little program, that will write the same things again and again? (I cannot copy and paste)

I can get tired of writing "selling steel sword" a thousand times in a row sometimes.. :(
 

HexMonkey

Administrator emeritus
Feb 5, 2004
2,240
504
New Zealand
You can use AppleScript to send some keystrokes to an application as follows:

Code:
tell application [Application name] to activate
tell application "System Events" to keystroke "selling steel sword"

You can then use a repeat loop to do this a fixed number of times or until a condition is met, for example:

Code:
tell application [Application name] to activate
repeat with i from 1 to 20
	tell application "System Events" to keystroke "selling steel sword"
end repeat

You might need to hit the return key after entering a phrase. To do that with AppleScript, just add "& return" after the keystroke command as follows:

Code:
tell application "System Events" to keystroke "selling steel sword" & return
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.