Sign in to follow this  
Followers 0
ali79

Filepaths from explorer?

5 posts in this topic

#1 ·  Posted (edited)

Let's say I have got explorer open and I click two files using control. Now I wish to press some hotkey so that I get the paths of these two files. How is it to be done... I was thinking of trying it with GetCurrentSelection like this:

Dim $selectedFiles
WinWaitActive("[CLASS:ExploreWClass]", "", 10)
If WinActive("[CLASS:ExploreWClass]", "") Then
     $selectedFiles = ControlCommand("", "", "[CLASS:SysListView32]","GetCurrentSelection") 
     MsgBox(262144,'Debug line ~' & @ScriptLineNumber,'Selection:' & @lf & 'selectedFiles' & @lf & @lf & 'Return:' & @lf & $selectedFiles);### Debug MSGBOX
 EndIf

but I wasn't getting anything, just 0. However this will only give me the file names (even if I got it to work). So, what should I do?

Thanks

Edited by ali79

Share this post


Link to post
Share on other sites



Hi,

Opt("WinTitleMatchMode", 4)
Global $ShellObject = ObjCreate("Shell.Application")
Dim $Pfade = ''

$WinList = WinList('[CLASS:ExploreWClass]')
For $i = 1 To $WinList[0][0]
    $Pfade &= _GetExplorerWinOpenedPath($WinList[$i][1], $ShellObject) & @CRLF
Next

MsgBox(0, "", "Pfade geöffneter Explorer-Fenster:" & @CRLF & @CRLF & $Pfade)


Func _GetExplorerWinOpenedPath($WinHandle, ByRef $ShellObject)
    If (Not IsObj($ShellObject)) And (Not ObjName($ShellObject) == 'IShellDispatch4') Then Return SetError(1, 0, '')

    For $Window In $ShellObject.Windows
        If ObjName($Window) == 'IWebBrowser2'  Then
            If $window.HWND = $WinHandle Then
                Return StringReplace(StringReplace(StringReplace($window.LocationURL, 'file:///', ''), '/', '\'), '%20', ' ')
            EndIf
        EndIf
    Next
    Return SetError(2, 0, '')
EndFunc

Mega


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

Thanks mega, this was interesting. However, I wish to get the file paths not in the url of explorer window but the file paths for files selected within by using mouse (ctrl + left-click).

Share this post


Link to post
Share on other sites

Hmmh, then I do not get what you need. Screenshot?


Scripts & functions Organize Includes Let Scite organize the include files

Yahtzee The game "Yahtzee" (Kniffel, DiceLion)

LoginWrapper Secure scripts by adding a query (authentication)

_RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...)

Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc.

MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times

Share this post


Link to post
Share on other sites

See #498391


"be smart, drink your wine"

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  
Followers 0