I compiled this with LSUIElement = true so the icon does not show in the Dock.
property appTitle : "Cloaking Device"
property instructions : "Allows you to hide disks that you do not want to appear on the desktop." & return & return & "These disks continue to be mounted." & return & return & ¬
"When you drag & drop to eject, you must select \"Eject All\" to eject invisible disks."
on run
path to me
tell application "Finder" to startup of disk of the result
if not the result then
activate me
"This application must be installed on the current startup disk."
tell me to display dialog the result with title appTitle buttons {"OK"} default button 1
return
end if
--
activate me
tell me to display dialog instructions with title appTitle buttons {"Cancel", "Cloak", "Uncloak"} default button 1
button returned of the result
if the result is "Cloak" then
my cloakDisk()
else if the result is "Uncloak" then
my uncloakDisk()
end if
end run ----------------------------------
on cloakDisk()
tell application "System Events"
set diskList to disks whose visible is true and startup is false -- list of disk records
set idList to {}
repeat with i from 1 to (count items of diskList)
set idList to (idList & {id of item i of diskList})
end repeat
end tell
activate me
tell me to choose from list idList with title appTitle with prompt "Choose a disk ..." OK button name "Hide"
set diskID to the result
if class of diskID is boolean then return -- user cancelled
tell application "System Events" to set visible of disk id (diskID as text) to false
tell application "Finder"
quit
delay 0.5
activate
end tell
end cloakDisk ----------------------------
on uncloakDisk()
tell application "System Events"
set diskList to disks whose visible is false -- list of disk records
set idList to {}
repeat with i from 1 to (count items of diskList)
set idList to (idList & {id of item i of diskList})
end repeat
end tell
activate me
tell me to choose from list idList with title appTitle with prompt "Choose a disk ..." OK button name "Show"
set diskID to the result
if class of diskID is boolean then return -- user cancelled
tell application "System Events" to set visible of disk id (diskID as text) to true
end uncloakDisk --------------------------