Page 1 of 1

Applescript

Posted: Sat May 29, 2010 3:27 pm
by Precastwig
Yay, Nerd talk.

Anyway.
I suck at coding so bad that all i can do is applescript,
But im stuck,
I'm trying to create a simple folder lock and i dont know the code for closing a finder window.
Here is what i have:

on opening folder this_folder
display dialog "Do you want a cookie?" default answer "Im not sure" buttons {"I give up", "Go"} default button 2
copy the result as list to {Text_returned}

if the button returned of the result is "I give up" then
tell application "Finder" to quit
else
if Text_returned is "******" then
quit
else
tell application "Finder" to quit
end if
end if
end opening folder

NOthing is wrong with it except for the close folder window things.
So urr yh,
Any ideas?
I've done a google search with no luck.

Re: Applescript

Posted: Sat May 29, 2010 3:51 pm
by rudel_ic

Re: Applescript

Posted: Sat May 29, 2010 3:54 pm
by Precastwig
Ok, how do i close a specific window, its not a Mac HD window, Its a folder. What would be the code for that?
tell application "Finder" to close Finder window "PS half images" (Thats the folder i want to lock, no money for guessing what im locking.)

Re: Applescript

Posted: Sat May 29, 2010 3:55 pm
by rudel_ic
Well, isn't the proper string in this_folder? Looks like it.

Edit: Note: You can't quit Finder at all. Ever. It's the mother process of all desktop operations or something like that. Akin to init on Unix.

Re: Applescript

Posted: Sat May 29, 2010 4:02 pm
by Precastwig
rudel_ic wrote:Well, isn't the proper string in this_folder? Looks like it.

Edit: Note: You can't quit Finder at all. Ever. It's the mother process of all desktop operations or something like that. Akin to init on Unix.
Like this?
on opening folder this_folder
display dialog "Do you want a cookie?" default answer "Im not sure" buttons {"I give up", "Go"} default button 2
copy the result as list to {Text_returned}

if the button returned of the result is "I give up" then
tell application "Finder" to close Finder window this_folder
else
if Text_returned is "******" then
quit
else
tell application "Finder" to close Finder window this_folder
end if
end if
end opening folder

Re: Applescript

Posted: Sat May 29, 2010 4:04 pm
by rudel_ic
Well, can't you just try it out?

Re: Applescript

Posted: Sat May 29, 2010 4:07 pm
by Precastwig
rudel_ic wrote:Well, can't you just try it out?
Yh its doesn't work.

Re: Applescript

Posted: Sat May 29, 2010 4:32 pm
by rudel_ic
I think you should go through the tutorials.

Re: Applescript

Posted: Sat May 29, 2010 4:38 pm
by Precastwig
rudel_ic wrote:I think you should go through the tutorials.
I have before,
I'll go through them again.