Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Get paths of selected items in an explorer window


  • Please log in to reply
38 replies to this topic
fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
The crash is a known problem at that part, it doesn't happen if you use 64bit AHK (but unfortunately some libraries aren't compatible to 64bit AHK yet).

20110123
  • Guests
  • Last active:
  • Joined: --

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.

fragman
  • Members
  • 1591 posts
  • Last active: Nov 12 2012 08:51 PM
  • Joined: 13 Oct 2009
It's working reliable most of the time, except with explorer windows which remain from a previous explorer (shell) crash. It doesn't have those in the list anymore and won't find them through COM.

ewerybody
  • Members
  • 70 posts
  • Last active: Feb 01 2017 01:55 PM
  • Joined: 18 Sep 2006
Excellent library!!! thanks a lot!

I have a small problem though:
Explorer_GetPath() returns:

p:\\[email protected]\folder\
when I'm on:
ftp://domain.de/folder/

must be the regex to trim the path variable. But I'm bad at that :/

Rapte_Of_Suzaku
  • Members
  • 901 posts
  • Last active: Jul 08 2011 02:12 PM
  • Joined: 29 Feb 2008
Sorry, didn't notice the replies until now! :oops:

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.

Crazy_Cat
  • Guests
  • Last active:
  • Joined: --
Is the result of using this script the same as > right-click on the file > check Properties > General (tab) > Location?

Posted Image :lol:

Rapte_Of_Suzaku
  • Members
  • 901 posts
  • Last active: Jul 08 2011 02:12 PM
  • Joined: 29 Feb 2008
That should be the same.

Rapte_Of_Suzaku
  • Members
  • 901 posts
  • Last active: Jul 08 2011 02:12 PM
  • Joined: 29 Feb 2008
Anyways, I (hopefully) fixed the ftp issue.

daniel z
  • Guests
  • Last active:
  • Joined: --
thank you for this script, it works perfectly fine. I have been looking to copy file path a very long time. i finally found something i can tweak and use to my needs thanks to a wonderful programmer such as yourself. Keep up the good work, and thanks again :D

INSGRAPHIZM
  • Members
  • 2 posts
  • Last active: Feb 28 2013 09:07 PM
  • Joined: 25 Feb 2013

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


Kangaroo
  • Members
  • 8 posts
  • Last active: Nov 04 2014 12:39 PM
  • Joined: 05 Dec 2012

Hi,

 

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?

 

regards, Kangaroo

 

 



sinkfaze
  • Moderators
  • 6367 posts
  • Last active: Nov 30 2018 08:50 PM
  • Joined: 18 Mar 2008

Check your other scripts to see what's conflicting with it.



Kangaroo
  • Members
  • 8 posts
  • Last active: Nov 04 2014 12:39 PM
  • Joined: 05 Dec 2012

any suggestions how I should do this?

 



ahk_bidou
  • Members
  • 3 posts
  • Last active: May 06 2013 07:23 AM
  • Joined: 12 Dec 2012

Hello,

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.

 

Thanks,



JMeneses
  • Members
  • 161 posts
  • Last active: Oct 30 2015 02:10 PM
  • Joined: 17 Feb 2011

Yes , my also try this

 

 062 : For window, in ComObjCreate("Shell.Application").Windows 

 063 :   Try if (window.hwnd==hwnd)

 064 :      Return,window