Jump to content

how to get the path of selected files from explorer (Windows 11)


 Share

Recommended Posts

Although the latest post is exactly on year old now (happy birthday, dear post!), I´d like to jump on this topic as it is the only one of its kind that touches my own topic:

How can I find out the full path of the currently active tab in the Explorer? This might sound silly as it was talked about that above. But no, the answer is not there.

What I have found so far is a very easy command to get the displayed path of the current tab:

$hExplorer = WinGetHandle("[REGEXPCLASS:^(Cabinet|Explore)WClass$]")
$hActiveTab = ControlGetHandle($hExplorer, "", "ShellTabWindowClass1")
$activePath = ControlGetText($hActiveTab, "", "")
MsgBox(0, "Explorer Tab Paths", "active tab path: " & $activePath, 4)

This works fine until you selected some folder like "Downloads" or "Videos" or such - you will not get the full path but only the translated name in short.

The full path can be retrieved by this:

$hExplorer = WinGetHandle("[REGEXPCLASS:^(Cabinet|Explore)WClass$]")
$oShell = ObjCreate("Shell.Application")

$i=0
For $oWindow in $oShell.Windows()
    if $oWindow.HWND = $hExplorer Then
        $i += 1
        $tabPath = $oWindow.Document.Folder.Self.Path
        MsgBox(0, "Explorer Tab Paths", $i & ". tab path: " & $tabPath, 4)
    endif
Next

Nice, but I don´t get the information which of the tabs is the active one!

So I have two solution for the two aspects, but I fail to put them together 😞

On the AHK forum I found this post: https://www.autohotkey.com/boards/viewtopic.php?f=83&t=109907 which might work (I did not install AHK just to try), but I am not able to translate the code into AutoIt code.

I appreciate any input on this!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...