I am trying to come up with a routine to do the same as an old utility called FileNote. FileNote does not work in Windows 11.
Simple routine: User does right click on a selected single file in the Explorer window. Then selects FileNote from context menu. FileNote then creates a txt file in the same folder, using the same filename with .txt extension.
My plan is to compile my script and put it on the context menu to be selected.
My initial problem is how to capture the path and the file name of the selected file.
I know how to get the final exe file onto the context menu. I am not concerned about that. I just need to capture the file that opened the context menu.
I am thinking I need to use GetControlItemText to grab the info I need. I have never used the command, and the instructions are not being understood by me. Once I have the string, I can use Separate to get the components and then do a simple WriteLn to make the txt file. Any chance of seeing real code performing this on File Explorer page?
Thanks for listening.
Need to grab path and filename of Windows Eplorer selected file.
Moderators: JRL, Dorian (MJT support)
- Dorian (MJT support)
- Automation Wizard
- Posts: 1417
- Joined: Sun Nov 03, 2002 3:19 am
Re: Need to grab path and filename of Windows Eplorer selected file.
I've been chatting to Marcus about this and we're of the opinion it's not possible to capture file name and path from a selected file in Windows Explorer.
You can, however, do it from a Custom Dialog using File Browse Buttons. You could even simply use Input.
Then use ExtractFileName and ExtractFilePath
I do understand though, that's not really what you're looking for.
You can, however, do it from a Custom Dialog using File Browse Buttons. You could even simply use Input.
Then use ExtractFileName and ExtractFilePath
I do understand though, that's not really what you're looking for.
Re: Need to grab path and filename of Windows Eplorer selected file.
In Windows File Explorer Ctrl + Shift + C will capture path and filename of a highlighted file or folder or group of files or folders. Therefore the following code. Not sure why but I have to run Ctrl + Shift + C twice but if it got me the result I'd run it 10 times in a script. I have not tested using an executable in the context menu, only by setting a hot key and running the script using that.
Good luck, Hope you can make it work. Be interested in seeing your finished product.
In any case I learned something new today and now have a new tool in my toolbox. I've always had to open a DOS box to get this information.
Good luck, Hope you can make it work. Be interested in seeing your finished product.
In any case I learned something new today and now have a new tool in my toolbox. I've always had to open a DOS box to get this information.
Code: Select all
Wait>0.5
Press ctrl
Press shift
send>c
Release shift
Release ctrl
Wait>0.3
Press ctrl
Press shift
send>c
Release shift
Release ctrl
GetClipboard>vFilePathnName
MDL>vFilePathnName
- Dorian (MJT support)
- Automation Wizard
- Posts: 1417
- Joined: Sun Nov 03, 2002 3:19 am
Re: Need to grab path and filename of Windows Eplorer selected file.
Well, that's a new one on me! Nice find, JRL! Thank you for your input.
Re: Need to grab path and filename of Windows Eplorer selected file.
Thanks JRL and all other inputs. Will try this on weekend. Looks perfect. How come I neverearned that shortcut after all these years? GRRRR!
Re: Need to grab path and filename of Windows Eplorer selected file.
I just stumbled on Ctrl + Shift + C and "Copy as Path" yesterday. Purely a coincidence that I also saw this post yesterday.
The lack of knowledge of the Ctrl + Shift + C "Copy as Path" shortcut among veteran advanced computer nerds led me to do some Googling on the subject. It appears that "Copy as Path" has been in the Windows File Explorer extended context menu since Windows 8. That said: I was not aware of the extended context menu until about 6 months ago. (So much for my advanced computer nerd credibility.) However "Ctrl + Shift + C" as a built in shortcut must be relatively new. in response to the Google search term:
"Windows File Explorer" "Ctrl + Shift + C "
Google's AI response is:
In Windows File Explorer, Ctrl + Shift + C does not have a predefined action. While Ctrl + C is used to copy, Ctrl + X to cut, and Ctrl + V to paste, there's no standard function for Ctrl + Shift + C within File Explorer. Ctrl + Shift + N is used to create a new folder, and Ctrl + D deletes the selected item and moves it to the Recycle Bin.
If Google's AI doesn't know about it, why would we mere mortals feel bad about the knowledge deficit?
The lack of knowledge of the Ctrl + Shift + C "Copy as Path" shortcut among veteran advanced computer nerds led me to do some Googling on the subject. It appears that "Copy as Path" has been in the Windows File Explorer extended context menu since Windows 8. That said: I was not aware of the extended context menu until about 6 months ago. (So much for my advanced computer nerd credibility.) However "Ctrl + Shift + C" as a built in shortcut must be relatively new. in response to the Google search term:
"Windows File Explorer" "Ctrl + Shift + C "
Google's AI response is:
In Windows File Explorer, Ctrl + Shift + C does not have a predefined action. While Ctrl + C is used to copy, Ctrl + X to cut, and Ctrl + V to paste, there's no standard function for Ctrl + Shift + C within File Explorer. Ctrl + Shift + N is used to create a new folder, and Ctrl + D deletes the selected item and moves it to the Recycle Bin.
If Google's AI doesn't know about it, why would we mere mortals feel bad about the knowledge deficit?