I have been trying to make a script that opens a certain file in folder for the case of opening a minecraft server. to navigate to the file the application have to know what the User/home folder is named on the computer the app is used on. you get a dialog box where you can type the name of the home folder. that part works fine. But is there any way you can get the app to remember whats written in the dialog box, so you dont have to write the name of your home folder every time you launch the application.
Here is a bit of the script
set home to (display dialog "Write the name of your user (home) folder" default answer "" buttons {"Cancel", "Ok"} default button 2)
set keyword to text returned of home
set buttonPressed to button returned of home
save text returned of home
tell application "Finder"
activate
open document file "LaunchServer.command" of folder "Bukkit server" of folder "desktop" of folder keyword of folder "Users" of startup disk
end tell
is this easier with an applescript based xcode application or what…
Thanks for all your help;)
Model: Imac
AppleScript: 2.3
Browser: Safari 535.2
Operating System: Mac OS X (10.6)
Thanks for the answer Stefan but is there a way to save the answer written in the dialog box? if the script looked like this i have to make the app remember the answer and thats one of the other reasons I need to know
Thanks again Stefan. your answer helped a lot
set MC_folder to (display dialog "Write the name of your minecraft server folder" default answer "" buttons {"Cancel", "Ok"} default button 2)
set keyword to text returned of MC_folder
set buttonPressed to button returned of MC_folder
tell application "Finder"
activate
open document file "LaunchServer.command" of folder keyword of desktop
property minecraftServerFolder : missing value
on open
selectFolder()
end open
on run
if minecraftServerFolder is missing value then
selectFolder()
end if
tell application "Finder"
open document file "LaunchServer.command" of minecraftServerFolder
end tell
end run
on selectFolder()
set minecraftServerFolder to (choose folder with prompt "select your minecraft server folder")
end selectFolder
At the first launch you’re prompted to select the folder. The information is persistent.
To change the folder drop something onto the app