Get paths of selected items in an explorer window
Actually, it works perfectly.
I have been using it now for several years now -- and even assigned it a hotkey since I use it so much. Yes, the file is 'copied' (really just a reference to the file), however since you are only extracting the text path when you use '%clipboard%' that is all you get.
As for copying a list of file names, I left out the simple use of parsing or even StringSplit because I thought that technique was obvious. Try it out, you will see what I mean.
Also, using the alternative code presented above, adds unreliability to the technique. First, there is an explorer option to not show the full path that may have been set. Second, the technique works in every file manager I have tried it in, including 'Everything' (I use it in Everything, Q-Dir, and Explorer). There is no need to try to locate a path separately -- an item that might not be available.
I forgot about the clipboard, good idea. But you'll still have to change "WinActive" as that only exists as a function. If you run that as it is you'll generate an error.
Personally I can't understand people who hide the path in explorer, it's kind of important to know where you are as the danger is the treeview (if they've not hid that either!) is scrolled away from the current folder so unless you recognise files off by heart you could be in any folder which could lead to unfortunate mistakes. It just seems abit stupid to me, like hiding file extensions. Most things have some potential for unreliability on others' machines eg. someone could use Ctrl+C as a different hotkey function.
I mentioned parsing because there are noobs who read the forum as well.
Anyway using COM is probably the best way of all.
I bet the location url is grabbed as "ftp://[email protected]/folder/". And then I didn't plan for urls that didn't start like file:///stuffhere, so trimming at -1+3 chops off the ft.
StringReplace, path, path, file:///would probably be better than the substr line.
Should the username before the domain be removed? I'll fix it quickly after work.
I was looking for a shortcut to easily copy+paste 1 or more selected file's path into emails, with the file:// formatting, on windows 7-8, and another one to open/run these filepath-s.
This is what I came up with. It works really well, I just wanted to share.
; ________________________________________ ; ; WINDOWS + C ; Copies the selected file's path to the clipboard (works with multiple file selection) and adds "file://" at the beginning of every path #c:: ; get selected file's path clipboard = SendInput, ^c ClipWait ; append file:// to the beginning clipboard = file://%clipboard% ; add file:// to every other line's beginning StringReplace, clipboard, clipboard, `r`n, `r`nfile://, All return ; ________________________________________ ; ; WINDOWS + O ; Opens/Runs a selected filepath in a text #o:: ; get selected text clipboardbackup := clipboardall clipboard := "" ClipWait, 0.05, 1 Send ^c ClipWait, 0.05, 1 result := clipboard clipboard := clipboardbackup ; run filepath run %result%, , UseErrorLevel return
When I use your script as "stand-alone" script, it works fine. But I have one overall script with all kinds of includes, so that I can invoke all kinds of scripts in one turn. But when I use your script via the include option it always gives ERROR as a return.
Do you know what to do about this?
Check your other scripts to see what's conflicting with it.
Recommended: AutoHotkey Boards
Tutorial for Newbies
Quick Search for Autohotkey|Beginner's RegEx Tutorial|Command Object Functions
COM Object Reference|COM - Basic Webpage Controls|Acc Library
I have been running this script for a few months smoothly.
Recently, when I run the script (using function Explorer_GetSelected() ), I get a dialog saying :
Error in #include file library.ahk 0x80020006 - unknown name Specifically : hwnd [some lines of the script] 062 : For window, in ComObjCreate("Shell.Application").Windows ---> 063 : if (window.hwnd==hwnd) 064 : Return,window [some other lines of the script] Continue running script ?
If I click yes, the script executes correctly, and does what is required.
Only annoyance is the popup.
I could handle the error, or ignore it, but I'm more interested in why this popup would appear out of the blue after months of good service.