Applescript command when closing a window

Discussion in 'Mac Programming' started by ElectricMan5, May 24, 2009.

  1. macrumors regular

    #1
    I keep my Halo 2 files in a hidden folder, with a . in front of the name. The only thing is, when I run it, it says that it cannot open because of the .

    I'm trying to make an applescript, which when its run, moves the folder to the desktop , open up the app, and when the app is closed, it moves it back to it's location.

    How do i move folders, cause when I record, nothing appears when I move the folder, and how do i issue a command when the window is closed?

    Thanks!
     
  2. macrumors 65816

    zmttoxics

    #2
    "mv" is the command.

    Example:
    mv /Users/user/path/to/.Halo /Users/user/Desktop

    You can also replace /Users/user/ with ~/.

    Example:
    mv ~/path/to/.Halo ~/Desktop
     
  3. macrumors 68040

    lee1210

    #3
    Whose machine are you hiding halo 2 on?
    or
    Who do you want/need to hide halo 2 from on your machine?

    Based on the answer to this, there might be a better way to achieve what you are wishing to achieve.

    -Lee
     
  4. macrumors regular

    #4
    I don't think those will make a difference...

    I just want a command. I have the command for moving, but nothing yet for moving the folder back when the program quits... Thanks!
     
  5. macrumors 68040

    lee1210

    #5
    I think it will make a difference.

    If you are wanting to run it on a machine that isn't yours, you might consider putting it on a thumb drive or something, that way there's nothing to worry about, you just take it with you. Then you aren't using resources that aren't yours (i guess you're using the CPU time while you're playing, but unless the machine should be crunching numbers all the time, the owner probably won't notice they're missing).

    If it's your own machine, but you just don't want others to know it's there you can probably accomplish this with multiple users and unix permissions. If you can't force others to use a separate login, you could make one for yourself just for playing the game, and make sure that the ownership of the folder that contains this folder isn't readable to anyone else, and the folder itself is not, etc.

    Otherwise, i would write a shell script that moves the folder to a non-hidden place, runs it, then when the game exits, renames it somewhere hidden. EDIT: i don't know applescript well. There is assuredly a way to do what i suggested using applescript, but i know shell better, so i'd do it that way.

    -Lee
     
  6. macrumors regular

    #6
    It's my own machine, and it has nothing to do with users. Please, I asked for what I want, I know what I'm doing. Also, mv /Users/user/path/to/.Halo /Users/user/Desktop doesn't work at all. I know mv is the code, the putting the path in doesn't work.
     
  7. macrumors 68040

    lee1210

    #7
    mkdir .hiddenfolder
    cd .hiddenfolder
    <create shell script, echome.sh, set to executable>
    Contents:
    Code:
    echo "This is the hidden program"
    cd
    <create shell script, runecho.sh, set to executable>
    Contents:
    Code:
    mv .hiddenfolder nothiddenfolder
    . ./nothiddenfolder/echome.sh
    mv nothiddenfolder .hiddenfolder
    
    When runecho.sh is run, it moves the hidden folder to a non-hidden folder, then runs the program, then moves the folder back to hidden.

    -Lee
     
  8. macrumors regular

    #8
    Is there a way to do this via Applescript though?
     
  9. macrumors 65816

    mysterytramp

    #9
    Yes, something like:

    Code:
    on run
    
    do shell script "mv ~/path/to/.Halo ~/Desktop"
    
    end run
    MRoogle "do shell script" and you should see plenty of examples here.

    And you may need to replace the /'s to //'s because AS uses the slash like an escape character.

    mt
     

Share This Page