Karl of AskTheAdmin had recently answered question about how to copy file’s path to clipboard in Vista . Windows XP doesn’t have such function natively and post had some 3rd party software suggestions in the comments.
It reminded me how easy it is to make custom operations using SendTo menu and simple AutoIt scripts.
SendTo is special Windows folder for setting up actions available from right-clicking file and choosing Send to sub-menu. It has few useful default actions and most of readers stop at that. But daring ones can improve that a lot!
SendTo folder resides in user profile folder:
C:\Documents and Settings\%username%\SendTo\
Shortcut to get there is Start > Run (Win+R) > sendto > Ok (Enter) . That opens same folder without having to browse there.
Command line argument
Lots of internal Windows mechanics work according to ancient DOS rules. When you use SendTo command what actually happens is following:
- Windows takes full name (including path) of file or folder you right-clicked
- and passes it to SendTo item you had chosen – in the form of command line argument.
So you can use absolutely anything (or shortcut to that anything) that accepts full file name as command line argument and SendTo would work perfectly with that.
So how complex it is to write custom program that would take file name passed by SendTo and copy it to clipboard?
If $CmdLineRaw Then ClipPut($CmdLine) Exit
That’s all. Compile and put into SendTo folder.
- $CmdLineRaw is AutoIt macros that holds command line parameters (in string form), need to check so it is not empty.
- $CmdLine holds number of arguments (we don’t need), $CmdLine holds first argument.
- So ClipPut() sends first command line argument to clipboard.
- Exit exits.
Easy, isn’t it? It’s simple demonstration how SendTo allows to easily feed files into AutoIt program. Program itself can be as complex as needed.