someone who knows applescript.. very quick question

Discussion in 'Mac Apps and Mac App Store' started by rock6079, Aug 20, 2004.

  1. macrumors 6502

    Jan 6, 2004
    i want to create an apple script that will launch a certain application and after it laucnehd just send a KeyPress of "return" key..

    trying to record it doesnt work...
    i was able to come up with this just out of logic, and a my very small understanding of applescript. the program i want to use doesnt have a dictionary. ive seen examples where it says "KeyPress Command "c"" for example, i tried doing "KeyPress Return" but it didnt work. so if n e one has ne ideas and can help, very appreciated

    tell application "Finder"
    open application application

    end tell
  2. Administrator


    Staff Member

    Feb 5, 2004
    New Zealand
    This should do it, just put the application name as the applicationName property.

    property applicationName : "" --Put the application name inside the speech marks
    tell application applicationName
    	activate --Open and activate the application
    	tell application "System Events"
    		tell process applicationName
    				key code 36 --Type the return key
    			on error theError
    				display dialog ("Sorry, an error occured:" & theError) buttons "OK" default button "OK" with icon stop
    			end try
    		end tell
    	end tell
    end tell
    If the script doesn't work, go to System Preferences and make sure the following option is checked:
    Universal Access->Enable access for assistive devices (at the bottom).

Share This Page