Kayboard script?

Discussion in 'Mac Programming' started by Poff, Feb 2, 2005.

  1. macrumors 65816

    Poff

    Joined:
    Sep 16, 2003
    Location:
    Stavanger, Norway
    #1
    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.. :(
     
  2. Administrator

    HexMonkey

    Staff Member

    Joined:
    Feb 5, 2004
    Location:
    New Zealand
    #2
    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
     

Share This Page