File chooser program

Bear with me on this one: You need to create the following folders:

“File Chooser” (anywhere)
inside, put folders called:
“Apps”
“Plug Data” (for the older, safer, plugs)
“Plugins” (for the plugins)

Now save the following script as an application called " File Chooser " (with the space at the front)


(* Path to users folder*)
list disks
set Hdrive to the first item of the result
tell application "System Events"
	set Uname to the current user's name
end tell
set Hpath to Hdrive & ":Users:" & Uname & ":"

(* Path to me *)
tell application "Finder"
	set PTapp to (path to me)
	set PTme to ((the container of (PTapp)) as alias) as string
end tell

(* Form of adress*)
tell application "System Events"
	set Uname to the current user's full name
end tell

(*Get application folder*)
tell application "Finder"
	set Pfol to list folder (PTme & "Apps") as alias without invisibles
end tell

(*Used?*)
if UsedTemplate's Beenused is not "Yes" then
	display dialog "Thankyou for downloading File Chooser by Timothy.G." buttons {"OK"}
	set UsedTemplate's Beenused to "Yes"
end if

(*Get plugins folder*)
set PTme to PTme
tell application "Finder"
	
	set apps to (PTme & "Apps")
	
	set plugs to (list folder (PTme & "Plugins") without invisibles)
end tell


(*Application script*)
set Pfol to {"Shut Down", "Sleep", "Log Out", "Eject", "Empty Trash"} & Pfol & {"Plugins", "Options"}
repeat
	set choice to (choose from list Pfol)
	if choice is {"Shut Down"} then
		tell application "System Events"
			shut down
		end tell
		return "User Canceled"
	else if choice is {"Sleep"} then
		try
			do shell script " pmset force -a hibernatemode 1" --activates Safe Sleep all the time
		on error
			display alert "Safe Sleep Activate failed"
		end try
		tell application "Finder"
			sleep
		end tell
		delay 5
		try
			do shell script " pmset force -a hibernatemode 1" --activates Safe Sleep all the time
		on error
			display alert "Safe Sleep Activate failed"
		end try
		tell application "Finder"
			sleep
		end tell
		delay 5
		
	else if choice is {"Empty Trash"} then
		tell application "Finder"
			empty
		end tell
	else if choice is {"Log Out"} then
		tell application "System Events"
			log out
		end tell
		return "User Canceled"
	else if choice is {"Eject"} then
		tell application "Finder"
			set cdName to do shell script "df | grep /dev/disk1 | sed -e 's@^.*/Volumes/@@'"
			if cdName is not equal to "" then
				set cdRef to disk cdName
				if local volume of cdRef is true and startup of cdRef is false and ejectable of cdRef is true then
					eject cdRef
				end if
			else
				display dialog "Error, no disc."
			end if
		end tell
	else if choice is {"Options"} then
		repeat
			display dialog "Options:" & return & return & "Click below" buttons {"New app", "Remove app", "Done"}
			set button to the button returned of the result
			if button is "New app" then
				set newapp to (choose file with prompt "Choose one or more apps to add. Cancel will quit the application.")
				tell application "Finder" to set theAlias to make new alias file at (Hpath & "Desktop:Basic file chooser:Apps") to newapp
			else if button is "remove app" then
				choose from list apps with title "Remove application" with prompt "Choose an application to remove from the list ." & return & return
				set choice to the result
				if choice is not false then
					set choice to "Gentfamdisc:Users:Tim:Appchooser:" & choice
					tell application "Finder" to move file choice to trash
					tell application "Finder" to empty trash
				end if
			else if button is "Done" then
				exit repeat
			end if
		end repeat
	else if choice is {"Plugins"} then
		set Pchoice to (choose from list plugs & {"Back"})
		if Pchoice is {"Back"} then
		else
			run script alias ((PTme & "Plugins:") & Pchoice)
			return "User Canceled"
		end if
	else if choice is false then
		exit repeat
	else
		tell application "Finder"
			open (PTme & "Apps:" & choice) as alias
		end tell
		exit repeat
	end if
end repeat

script UsedTemplate
	property Beenused : missing value
end script

You’re all set. But I have made some plugs if you want them:

Game folder plug:
Create a folder and put aliases to all your games inside. Then put this as a script document into the plugins folder:


tell application "Finder"
	set PTme to (container of (container of (path to me)) as alias) as string
end tell
set theAlias to (PTme & "Plug Data:Games Data.scpt") as alias
set MyData to load script theAlias
set PDpath to PTme & "Plug Data:Games Data.scpt"

if MyData's Beenused is not true then
	set MyData's Gameslocal to (choose folder with prompt "Choose your Games folder (must be aliases or applications, not a folder.):")
	set MyData's Beenused to true
end if

tell application "Finder"
	if (MyData's Gameslocal exists) is false then
		set MyData's Gameslocal to (choose folder with prompt "Choose your new Games folder:")
	end if
	
	store script MyData in (PTme & "Plug Data:Games Data.scpt") replacing yes
	
end tell

tell application "Finder"
	set Games to (list folder MyData's Gameslocal without invisibles)
	set Game to (choose from list (Games & {"new game folder"}) cancel button name "Back")
	if Game is {"new game folder"} then
		set MyData's Gameslocal to (choose folder with prompt "Choose your new Games folder:")
		store script MyData in (PTme & "Plug Data:Games Data.scpt") replacing yes
		run script PTme & " File Chooser .app"
	else if Game is false then
	else
		set Gamename to (MyData's Gameslocal & Game) as string
		open alias Gamename
		return "User Canceled"
	end if
	run script alias (PTme & " File Chooser .app")
end tell

Adium lognuke

This malicious plugin will change your adium status from available to invisible very rapidly causing all your microsoft-using contacts to get thoes annoying popups all down one side of the screen. :wink:
Save it as a script in the plugiins folder.


tell application "Finder"
	set PTme to (container of (container of (path to me)) as alias) as string
end tell
set Bomb to the text returned of (display dialog "Number of logs:" default answer "10" buttons {"OK"} default button 1)
repeat Bomb times
	tell application "Adium"
		set my status type to available
		set my status type to invisible
	end tell
end repeat
run script alias (PTme & " File Chooser .app")

Word Game

Here is a little game that is sometimes played at parties. In script form. Save it as a script in your plugins folder:


tell application "Finder"
	set PTme to (container of (container of (path to me)) as alias) as string
end tell
set Mname to the text returned of (display dialog "Male Name:" default answer "" buttons "OK" default button 1)
set Fname to the text returned of (display dialog "Female Name:" default answer "" buttons "OK" default button 1)
set Mplace to the text returned of (display dialog "Place ( insert \"a \" for places like \"a pub, a cinema\":" default answer "" buttons "OK" default button 1)
set Msaid to the text returned of (display dialog "What did he say:" default answer "" buttons "OK" default button 1)
set Fsaid to the text returned of (display dialog "What did she say:" default answer "" buttons "OK" default button 1)
set DaEnd to the text returned of (display dialog "What happened:" default answer "" buttons "OK" default button 1)
say (Mname & " met " & Fname & " in " & Mplace & ". " & Mname & " said " & Msaid & " to which " & Fname & " replied " & Fsaid & ". Then " & DaEnd) using "Bruce"
run script alias (PTme & " File Chooser .app")

To build your own plugs, use this simple template. Running a such script from the plugins folder as an application will finish by launching the file chooser afterwards.


tell application "Finder"
	set PTme to (container of (container of (path to me)) as alias) as string
end tell


(*Plugin code*)


run script alias (PTme & " File Chooser .app")

Sorry if it’s a bit simple/long, I’m learning!
Have fun!