PDA

View Full Version : Applescript command when closing a window




ElectricMan5
May 24, 2009, 12:54 PM
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!



zmttoxics
May 24, 2009, 12:56 PM
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!

"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

lee1210
May 24, 2009, 01:14 PM
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

ElectricMan5
May 24, 2009, 01:46 PM
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

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!

lee1210
May 24, 2009, 01:51 PM
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

ElectricMan5
May 24, 2009, 02:18 PM
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

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.

lee1210
May 24, 2009, 03:29 PM
mkdir .hiddenfolder
cd .hiddenfolder
<create shell script, echome.sh, set to executable>
Contents:
echo "This is the hidden program"
cd
<create shell script, runecho.sh, set to executable>
Contents:
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

ElectricMan5
May 25, 2009, 01:09 PM
mkdir .hiddenfolder
cd .hiddenfolder
<create shell script, echome.sh, set to executable>
Contents:
echo "This is the hidden program"
cd
<create shell script, runecho.sh, set to executable>
Contents:
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

Is there a way to do this via Applescript though?

mysterytramp
May 25, 2009, 09:20 PM
Is there a way to do this via Applescript though?

Yes, something like:

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