Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate

Get paths of selected items in an explorer window

  • Please log in to reply
38 replies to this topic
  • Members
  • 3 posts
  • Last active: May 06 2013 07:23 AM
  • Joined: 12 Dec 2012


Thanks for the feedback !

I cannot reproduce that issue anymore. I guess your code code would work.


  • Members
  • 21 posts
  • Last active: Oct 25 2019 04:53 AM
  • Joined: 02 Oct 2012

worked fine for me a big thanks


lol i was using the manual method right click>copy path

  • Members
  • 2 posts
  • Last active: Jun 27 2014 05:24 PM
  • Joined: 18 May 2014

Is it possible to have a "for each" of whatever is in the "sel" variable ?


sel := Explorer_GetSelected()


I want to run a program on each element of my selection.


Thanks !

  • Members
  • 8 posts
  • Last active: May 21 2015 08:38 AM
  • Joined: 29 May 2014



It works fine when I assign a shortcut key. But when I include it in right click option via WinXp Registry-> HKCR\*\shell\CopyFullPath\command It gives file or folder name when I select only one. If I select multiple objects It results none. How it could be fixed?


I hope I would get your support that I am trying myself for 6 months.

  • Members
  • 2 posts
  • Last active: Jun 27 2014 05:24 PM
  • Joined: 18 May 2014

Anyone with an example of how to loop through multiple selection items ?


using Explorer_GetSelected()


Trying to apply a .exe on each item selected in the explorer.


Thanks :)

  • Members
  • 2 posts
  • Last active: Mar 07 2015 03:26 AM
  • Joined: 05 Mar 2015

I use this all the time and it is great.  The only pitfall that I wish I knew how to correct is that Explorer_GetSelected() is picky about which order you select things.  For example, if you click and drag 4 files starting with 1 then 2,3,4.  The first file from sel will be 4.  If you do it the opposite, then the first file will be 1.


I have a macro that makes booklets and divides pdfs into even/odd pages, reverses pdfs in one process.  Things have to get jumbled up a very particular way.  Unfortunately, if you select the files in consistently (which I do and other people using the program will also), then things will go in the wrong order and will be printed wrong, which is really bad.  


The code is way over my head in this library, but is there a way of keeping the order the same (alphabetical would be fine, or simply the order they appear in Windows) regardless of how one select/drags?

  • Members
  • 2 posts
  • Last active: Mar 07 2015 03:26 AM
  • Joined: 05 Mar 2015

Well, this is quite easy in AHK I've discovered.


Simply adding the command:


Sort sel, d`n


This will alphabetize a string delimited by a "`n."  This language... is my kind of language.

  • Members
  • 70 posts
  • Last active: Feb 01 2017 01:55 PM
  • Joined: 18 Sep 2006

I have the same thing with the the line:

        for window in ComObjCreate("Shell.Application").Windows
====>       if (window.hwnd==hwnd)
                return window

And the same popup. And I also remember it to work flawlessly. Is that something that came with a latest Autohotkey update?

Also the last line buggs me. It's complaining that it cannot run Trim with more than 1 argument! And it's directly displaying the line break in the error window:

Specifically: Trim(ret, "

	089: if selection  
	090: collection := window.document.SelectedItems
	091: Else
	092: collection := window.document.Folder.Items
	093: For item, in collection
	094: ret .= item.path "
	095: }
--->	099: Return,Trim(ret, "

So I catched the first thing and made the Trim only Trim(ret)

But that's probably all not like intended? :/

  • Members
  • 45 posts
  • Last active: Jan 23 2016 07:15 AM
  • Joined: 10 Sep 2011

Thanks a lot Rapte_Of_Suzaku. Works perfectly.