Xcode Applescript Quit my app

Discussion in 'Mac Programming' started by lynkynpark86, Mar 20, 2010.

  1. lynkynpark86 macrumors 6502

    I'm trying to make my app quit itself by pushing a button. I could just connect the button to application with terminate, but then it wouldn't run the script it is attached to. I want something like this:
    tell window "main window"
    set varact to contents of text field "action"
    if varact is "beep"
    -- do nothing
    end if
    end tell
    terminate myapp
    I want to know how to make the script tell the application it is controlling to quit. HELP!
  2. kainjow Moderator emeritus


    Jun 15, 2000
    It's a little unclear what you're doing and why, but this is the standard way to quit an app in AppleScript:

    tell application "Preview" to quit
    If you're already in the "tell application" block, you can just use "quit".
  3. lynkynpark86 thread starter macrumors 6502

    Not quite

    Yes, that would normally work, but I want my app to quit itself. If app123 has "tell application 'app123' to quit" it will get an error because it tries to quit before it reads the end tell. I want it to tell the window to preform the "terminate" action AFTER it runs the script, so i cant connect the button to the application with terminate as the action

Share This Page