Re: drag/drop file-icon on tcl-script? on windows
- From: "slebetman@xxxxxxxxx" <slebetman@xxxxxxxxx>
- Date: 5 Apr 2006 03:51:41 -0700
alten wrote:
Eric Taylor wrote:
I'm on windows. I have a few tcl scripts where I'd like to
drag a file onto the programs Icon, or it's shortcut, and
be able to use it like I do with most other programs.
Is there a way to get the tcl program to launch and have argv(1..n) be
the dropped file names? Sure beats drilling down 5 levels in a file
dialog if you can simply reach the file with your mouse.
Any ideas?
Wrap your script in a batch file.
:: THIS IS FOR WINDOWS CMD.exe NOT W95 COMMAND.COM!
::if 0 {
if not {%1}=={} set myFiles=%*
start tclkit "%~f0" & exit
::NOW THE TCL STARTS . . . }
wm wi .
if {[info exists env(MYFILES)]} {
foreach f [string map {\\ \/} $env(MYFILES)] {
tk_messageBox -message "Doing something with \n$f"
}
}
tk_messageBox -message Done.
exit
I assume that you have tclkit.exe in your path.
something doesn't work with my 'file normalize', so I used 'string map'
instead. Something is also wrong in my 'exec', and the files won't
pass correctly to, for example, notepad.
Most people on windows have ActiveState so he's more likely to have
tclsh and wish in his path. Replace the start tclkit bit with start
wish and you will have correct behavior of file normalize.
Your batch file generated an error for me:
invalid command name :: while executing
:: THIS IS FOR WINDOWS CMD.exe NOT W95 COMMAND.COM!
The following batch file works perfectly:
::if 0 {
if not {%1}=={} set myFiles=%*
start wish "%~f0" & exit
:: }
wm wi .
if {[info exists env(MYFILES)]} {
foreach f [string map {\\ \/} $env(MYFILES)] {
tk_messageBox -message "Doing something with \n$f"
}
}
tk_messageBox -message Done.
exit
The ::if 0 { trick is neat ;-)
.
- References:
- drag/drop file-icon on tcl-script? on windows
- From: Eric Taylor
- Re: drag/drop file-icon on tcl-script? on windows
- From: alten
- drag/drop file-icon on tcl-script? on windows
- Prev by Date: Re: question on .f.b.etc widget heirarchy and -in
- Next by Date: Re: drag/drop file-icon on tcl-script? on windows
- Previous by thread: Re: drag/drop file-icon on tcl-script? on windows
- Next by thread: Re: drag/drop file-icon on tcl-script? on windows
- Index(es):
Relevant Pages
|