Jump to content
Sign in to follow this  

Windows Explorer Current Path in Windows 7/Vista

Recommended Posts

I've been looking for a clean way to get the current path of a explorer window in Windows 7/Vista and have yet to come across anything.

What I have found is a stellar solution for Windows XP: http://www.autoitscript.com/forum/index.php?showtopic=89833

Has anyone succeeded in getting this (above) script to work in Windows Vista or 7? I don't understand why it wouldn't work in 7 -- the class for an explorer window is still CabinetWClass.

Any suggestions that might help get this working? Or any other solutions that might solve this problem?--I could always use @OSVersion and fork for XP and Vista/7.



After thinking about this some more, I have something that will work. *Note: I haven't tested on Vista yet, only 7.

;;;This is the code that would go in your code, does the string analysis to get the path
for $i = 1 to $var[0][0]
    If @OSVersion = "WIN_7" Then
        $string = _GetWindowsExplorerPath($var[$i][1])
        $string = StringReplace($string, "Address: ", "")
        $string = StringSplit($string, @CRLF)
        MsgBox(0,"", $string[1])
    ElseIf @OSVersion = "WIN_VISTA" Then
        $string = _GetWindowsExplorerPath($var[$i][1])
        $string = StringReplace($string, "Address: ", "")
        $string = StringSplit($string, @CRLF)
        MsgBox(0,"", $string[1])
        MsgBox (0, "", _GetWindowsExplorerPath($var[$i][1]))

;;This gets added to the function
;;It goes below this line:
;;If ($className[2] <> "ExploreWClass" And $className[2] <> "CabinetWClass") Then Return SetError(1, 0, "")

If @OSVersion = "WIN_7" Then Return WinGetText($hWnd,"")
If @OSVersion = "WIN_Vista" Then Return WinGetText($hWnd,"")

Hopefully there's a less messy solution out there, but for now this seems like it could work.

Edited by cvocvo

Share this post

Link to post
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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...