## easy_launch.tcl ## DIR で指定したディレクトリにあるファイルに関する、 ## 単純なランチャー。習作です。 ## 日本語で名前がついてるファイルはうまくいきません (^_^;; set FONT {{MS ゴシック} 10 normal} cd "/Documents and Settings/user/デスクトップ" #wm attributes . -toolwindow 1 wm iconify . proc my_run { comm } { exec cmd /c start "$comm" } proc my_exit { } { destroy . } proc mymain { } { toplevel .w wm title .w "どれにしますか?" button .w.b -text "Quit" \ -relief flat -overrelief raised -foreground red \ -command my_exit pack .w.b -fill x set DIR "D:\\\\HOME\\\\Download" ## dir コマンドには \\ という文字列を渡すので、その ## ためには \\\\ と指定しないといけない、という‥ (^_^; set keys "0123456789abcdefghijklmnop" set keymax [expr [string bytelength $keys] - 1] set fnx 0 # set fid [open "| ./usr-local/bin/find $DIR -type f " r] set fid [open "| cmd /c dir $DIR " r] while {! [eof $fid] } { set line [gets $fid] set mm -1 regexp {^[0-9\/]+[ \t]+[0-9:]+[ \t]+[0-9,]+} $line mm set xl [string bytelength $mm] if { 5 < $xl && $fnx < $keymax } { set fnx [expr $fnx + 1] set fname [string trim [string range $line $xl end]] set fpath "" ; append fpath $DIR "\\" $fname set fpath [regsub -all {\\+} $fpath {\\\\}] # set fpath [regsub -all {\#} $fpath {\\\#}] set linez "" append linez {[} [string index $keys $fnx] {] } $fname button .w.px${fnx} -text $linez \ -relief flat -overrelief raised \ -command \ " .w.px${fnx} configure -foreground red ; \ my_run {$fpath} " pack .w.px${fnx} -anchor nw bind .w " my_run \"$fpath\" " } } bind .w {my_exit} bind .w { destroy .w ; mymain } } mymain