以下applescript可以实现
1、同一程序切换是否显示隐藏文件
2、自动重启finder,并且打开重启以前的窗口
附件中一个是源代码,一个是可以直接运行的application,你可以把后者拖到finder的工具栏上:
复制内容到剪贴板
代码:
try
do shell script "defaults read com.apple.finder AppleShowAllFiles"
on error
get 0
end try
set i to (result + 1) mod 2 -- Get opposite of current value
tell application "Finder"
activate
get item (i + 1) of {"Hide", "Show"}
display dialog (result & " all hidden files in Finder?") buttons {"Cancel", (result & " Hidden Files")} default button 2 with icon note
quit
end tell
delay 0.5
try
do shell script "defaults write com.apple.Finder AppleShowAllFiles " & i
launch application "Finder"
on error errorMsg number errorNum
display dialog "Error (" & errorNum & "):" & return & return & errorMsg buttons "Cancel" default button 1 with icon caution
end try[
本帖最后由 laohoupi 于 2007-12-14 22:17 编辑 ]