Resolved Applescript: Launching self-contained app trouble

Discussion in 'Mac Programming' started by 1theo0, Oct 12, 2012.

  1. 1theo0, Oct 12, 2012
    Last edited: Oct 15, 2012

    1theo0 macrumors newbie

    1theo0

    Joined:
    Jul 21, 2012
    #1
    There's an annoying launcher for Harry Potter and the Chamber of Secrets, so I wanted to make a script that includes the whole game, and when clicked, opens the app. It never works, no matter what I do! Help me please. I attach here the zipped app.
    Here are my attempts:

    1.

    set applocation to POSIX path of ":Contents:Resources:Harry Potter II:Harry Potter CoS"
    try
    set command to "open" & quoted form of applocation
    do shell script command
    end try

    2.

    set applocation to POSIX path of ":Contents:Resources:Harry Potter II:Harry Potter CoS"
    try
    set command to "open as alias" & quoted form of applocation
    do shell script command
    end try

    3.

    set applocation to POSIX path of "Contents:Resources:Harry Potter II:Harry Potter CoS"
    do shell script "open " & applocation

    4.

    open ":Contents:Resources:Harry Potter II:Harry Potter CoS"
     

    Attached Files:

  2. 1theo0 thread starter macrumors newbie

    1theo0

    Joined:
    Jul 21, 2012
  3. 1theo0, Oct 15, 2012
    Last edited by a moderator: Oct 15, 2012

    1theo0 thread starter macrumors newbie

    1theo0

    Joined:
    Jul 21, 2012
    #3
    Hooray!

    Ha! I figured it out.
    I share it here, in case anyone else needs it. To use it, just drop your Harry Potter II folder from the installation disc into the Contents/Resources folder :D. I also made a mod so you don't need the cd to play the game- a small image containing a file the game checks for in order to run! You have 3 minutes to load the game before the image unmounts itself! Enjoy!

    The code:
    Code:
    set image to (path to me as string) & "Contents:Resources:HP2.dmg"
    set HP2Volume to "HP2"
    set pathtoapp to (path to me as string) & "Contents:Resources:Harry Potter II"
    do shell script "hdiutil mount" & space & quoted form of POSIX path of image
    tell application "Finder"
    	activate
    	open application file "Harry Potter CoS" of folder pathtoapp
    end tell
    delay 180
    tell application "Finder"
    	eject HP2Volume
    end tell
    PS. I made the icon, it looks a bit weird, sorry!
     

    Attached Files:

Share This Page