Trying to script something using Applescript

Discussion in 'Mac Apps and Mac App Store' started by robot62155, May 20, 2012.

  1. robot62155 macrumors member

    Joined:
    Jun 5, 2011
    #1
    Hello! I am trying to script something that will type the address of a server into my Minecraft game. There is a text box, but when the script runs everything works except for the keystroke. Instead of typing in the words it says "Can't make "MCDisney.us" into type integer." Mcdisney.us is what I want it to type. This is the script. Can you please help me?

    display dialog "Would you like to play MCDisney?" buttons {"Yes", "No"}
    set button_r to the button returned of the result

    if the button_r is "yes" then
    tell application "Minecraft"
    activate
    end tell
    delay 10
    say "Please click on direct connect"
    delay 5
    tell "sytem events"
    keystroke "MCdisney.us"
    end tell
    end if

    if the button_r is "No" then
    end if
     
  2. Intell macrumors P6

    Intell

    Joined:
    Jan 24, 2010
    Location:
    Inside
    #2
    Try this:

    Code:
    display dialog "Would you like to play MCDisney?" buttons {"Yes", "No"}
    set button_r to the button returned of the result
    
    if the button_r is "yes" then
    	tell application "Minecraft"
    		activate
    	end tell
    	delay 10
    	say "Please click on direct connect"
    	delay 5
    	tell application "system events"
    		keystroke "MCdisney.us"
    	end tell
    end if
    
    if the button_r is "No" then
    end if
     
  3. robot62155 thread starter macrumors member

    Joined:
    Jun 5, 2011
    #3
    I got it

    I delayed the time between when I told the application "System events" and keystroked. Thanks for replying!
     

Share This Page