Hey,
I'm looking to gather a list of all selected files in a windows explorer window.
I.E. Say I have the My Documents Folder open, and select 5 files out of say 20 in the folder, I would like to replace whatever is in the clipboard with those five entries. I created a context menu item that I can right click and run that will add whatever I have selected to the clipboard and I can make it replace or append (right now append)

The problem I am having is that Windows doesn't return those 5 items in a list (that I can find), it just runs 5 separate instances of the program, so if I replaced the clipboard when the .pl script runs, the only data in the clipboard would be whatever the last file/folder ran that was passed into the .pl script not a "list" of all 5 files/folders.

I figured out a way to get it "closer" by doing a file listing of the whole directory, and then comparing the first "section" or whatnot of the clipboard and if it doesn't contain a similar term as the file/folder listing, then it replaces the clipboard otherwise it just appends,

The problem with this is that say I ran the script in the folder once already if I go back to that same folder without clearing the clipboard initially or putting something else on the clipboard, it won't realize that it needs to replace the contents and will continue to append, which then it will contain more items then I want,

This problem has been bugging me and I can't think of a good solution to it. If there is a way to get a "list" of all the selected files this would be SIMPLE but I can't figure that out.

Does someone know how I can get a list of the files selected?

Thank you,
Onaclov

I would make the .pl file, look for a temp file. Something like clpdata.dat or something, and have perl write the entry to the temp file. Then, I would have it scan the process list for other instances of my program... and when I see that I am the last process (assuming windows launches these sequentially) open the file, copy to the clipboard, and delete the file......I'll think about this one today.... KevinADC might have a better solution to this one.

I thought of that "kinda" but the problem is right now I call it via:
cmd.exe /c myscript.pl %1

it will only run them one at a time, so it won't run the "second instance" until the first is done, and by that time, the second one will only be aware of itself, and not see anyone else and think that it's alone and thus replace the clipboard or append depending on the action I specified in my script.

I was thinking if there was a way to "thread it" that would work, but it appears to only run them one at a time, and won't run the next one until the first (or previous) returns.

as far as I know anyways.

I suppose I found a "way around" using the clipboard, for anyone interested check out my blog, I still want to get the entire selected file list but I suppose I can't seem to figure it out at this point.
Onaclov Nation

This article has been dead for over six months. Start a new discussion instead.