Jump to content

Filepath of a file selected in explorer?


Recommended Posts

Hi,

Is it possible to get the path of a file selected in the file browser / explorer?

Or is it possible to use some kind of hotkey combination which copies the path of a selected file to the clipboard?

Looking for suggestions,

Thank you :mellow:

Edited by nf67
Link to comment
Share on other sites

How about setting up a shortcut to a script in the context menu (right click).

then you can use "FileGetLongPath" or whatever to put the info where you want it.

Then all you have to do is right click the file, and click your script shortcut.

good luck!

Bill

Link to comment
Share on other sites

Compile as "pathtest.exe"

Global $sFilePath
If $CmdLine[0] > 0 Then
    $sFilePath = $CmdLine[1]

EndIf
MsgBox(4096, "debug", "$sFilePath= " & $sFilePath)

Then run this:

$path = @ScriptDir & "\" & "pathtest.exe"
RegWrite("HKEY_LOCAL_MACHINE\Software\Classes\*\Shell", "pathtest")
RegWrite("HKEY_LOCAL_MACHINE\Software\Classes\*\Shell\pathtest", "Command")
RegWrite("HKEY_LOCAL_MACHINE\Software\Classes\*\Shell\pathtest\Command", "", "REG_SZ", '"' & $path & '"' & " " & '"%1"')
Link to comment
Share on other sites

I did a search on 'explorer selected' and got a few results. Try here or here

Link to comment
Share on other sites

Take also a look at this nice example, though I think I remember it only works on XP, but surley with some tweaking (change control classes of explorer in line with @OSVersion?) it should work on Vista or Win7 as well.

Link to comment
Share on other sites

:P That's funny KaFu, you posted the same link as I did (2nd link).

But hey.. guess what. Windows 7 doesn't use a listview anymore for Explorer windows. It uses that @#*$ 'DirectUIHWND' control type. Argh.. we're going to need to figure out a way to work with the DirectUI interface.

Maybe Monoceres or trancexx might be willing to investigate possible ways to interact with these new interfaces. (just volunteering some names :mellow: )

*edit: that link was just to get the folder path of what was being browsed.. I was thinking of how to get the actual files selected.

Edited by Ascend4nt
Link to comment
Share on other sites

Seems like Authenticity and trancexx already pushed into that direction in this thread here...

This thread also seems to contain some useful snippets.

This is what I tried so far, at least there seems to be happening something :mellow:...

#include <WinAPI.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

; http://www.autoitscript.com/forum/index.php?showtopic=98947&view=findpost&p=711318

Opt("WinWaitDelay", 0)
Opt("GUIOnEventMode", 1)
Opt("MustDeclareVars", 1)

Global $oMyError = ObjEvent("AutoIt.Error", "_ErrFunc")
Global $hOLEACC = DllOpen("oleacc.dll")

Global $hWnd_DirectUIHWND3 = ControlGetHandle("[CLASS:CabinetWClass]", "", "[CLASSNN:DirectUIHWND3]")
if not IsHWnd($hWnd_DirectUIHWND3) then Exit

Global $oAccessibleObject = _AccessibleObjectFromWindow($hWnd_DirectUIHWND3)

If IsObj($oAccessibleObject) Then
    ; http://msdn.microsoft.com/en-us/library/dd318466%28v=VS.85%29.aspx
    ; ConsoleWrite("accChild: " & $oAccessibleObject.accChild($Param) & @CRLF) ;<-
    ConsoleWrite("accChildCount: " & $oAccessibleObject.accChildCount & @CRLF)
    ConsoleWrite("accDefaultAction: " & $oAccessibleObject.accDefaultAction & @CRLF)
    ConsoleWrite("accDescription: " & $oAccessibleObject.accDescription & @CRLF)
    ConsoleWrite("accFocus: " & $oAccessibleObject.accFocus & @CRLF)
    ConsoleWrite("accHelp: " & $oAccessibleObject.accHelp & @CRLF)
    ; ConsoleWrite("accHelpTopic: " & $oAccessibleObject.accHelpTopic($Param) & @CRLF) ;<-
    ConsoleWrite("accKeyboardShortcut: " & $oAccessibleObject.accKeyboardShortcut & @CRLF)
    ConsoleWrite("accName: " & $oAccessibleObject.accName & @CRLF)
    ConsoleWrite("accParent: " & $oAccessibleObject.accParent & @CRLF)
    ConsoleWrite("accRole: " & $oAccessibleObject.accRole & @CRLF)
    ConsoleWrite("accSelection: " & $oAccessibleObject.accSelection & @CRLF)
    ConsoleWrite("accState: " & $oAccessibleObject.accState & @CRLF)
    ConsoleWrite("accValue: " & $oAccessibleObject.accValue & @CRLF)
EndIf

$oAccessibleObject = 0
DllClose($hOLEACC)
Exit

Func _AccessibleObjectFromWindow($hWnd)
    Local $sIID_IAccessible = "{618736E0-3C3D-11CF-810C-00AA00389B71}"
    Local $tGUID = _WinAPI_GUIDFromString($sIID_IAccessible)
    Local $pGUID = DllStructGetPtr($tGUID)
    Local $aCall = DllCall($hOLEACC, "int", "AccessibleObjectFromWindow", _
            "hwnd", $hWnd, _
            "dword", 0, _ ; OBJID_WINDOW
            "ptr", $pGUID, _
            "idispatch*", 0)
    If @error Or $aCall[0] Then
        Return SetError(1, 0, 0)
    EndIf
    Return $aCall[4]
EndFunc   ;==>_AccessibleObjectFromWindow

Func _ErrFunc()
    ConsoleWrite("--- COM Error, number = " & Ptr($oMyError.number) & ", description: " & $oMyError.windescription)
EndFunc   ;==>_ErrFunc
Link to comment
Share on other sites

Ahh, good find KaFu. The 'something' does appear to be happening :mellow:! Can't make heads or tails of it mysellf

I was looking at the DirectUI/UIPower site, and it has this page on DirectUI ListView Methods. Not sure if that's IDispatch type of stuff or not? *shrug* All I know is I can't make it work myself.

There is someone that figured out how to make Windows Explorer use the old SysListView32 format, but I don't see it as a good long-term solution..

Link to comment
Share on other sites

  • 4 months later...

;) That's funny KaFu, you posted the same link as I did (2nd link).

But hey.. guess what. Windows 7 doesn't use a listview anymore for Explorer windows. It uses that @#*$ 'DirectUIHWND' control type. Argh.. we're going to need to figure out a way to work with the DirectUI interface.

Maybe Monoceres or trancexx might be willing to investigate possible ways to interact with these new interfaces. (just volunteering some names ;) )

*edit: that link was just to get the folder path of what was being browsed.. I was thinking of how to get the actual files selected.

HEI finally!! i've the same iusse! (with win7 x64bit):

it' hours i'm reading :) but i can't find my solution:

like to save the .txt of a notepad in a different location?

i watch names with AutoItWin Info and i find out ToolbarWindow32,

what if i want to edit that "box" ??

i tried

-ControlSetText("Salva con nome", "", "CLASS:ToolbarWindow32; INSTANCE:3]", "C:\")

or with click

-ControlClick("Salva con nome", "", "ToolbarWindow32")

or with a normal Send

But noone worked=(

i'm at the beginning please help me!=( (i've read example script but not find for this!)

[and then: what if i'd like to write in DirectUIHWND for a research? (while saving..)what should i do? ControlSend("Salva con nome","","[CLASS:DirectUIHWND; INSTANCE:3]","ciao"); doesn't work.. ]

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...