How to retrieve File fullpath from Explorer ?
http://www.autohotke...p?p=86542#86542Foreword: I was trying to help Zak M. in the Ask for Help Topic: Select a file and copy its location and my find is very helpful for me too! I thank him for that!
Solution: Create a "Drag and Drop" enabled GUI and drag the files to it with MouseClickDrag . Handle the retrieved full path of file(s) in GuiDropFiles label as required.
The title of this post might sound tricky, as I have mentioned it as "Explorer" instead of "Windows Explorer". It is so because this trick applies to any iconic file visible to naked eyes, Like:
TreeView & List View and Addess bar icon in "Windows Explorer"
Files on the Desktop
Shortcut links on the Quick Launch
File Open / Save DialogHere is a basic example:SetBatchLines, -1 SetBatchLines, 1 CoordMode, Mouse, Screen Gui, +AlwaysOnTop -Caption +Border +ToolWindow Gui, Show, x0 y0 w9 h9 Hide, AHK.WE2CB.DND.GUI Return #LButton:: MouseGetPos, X, Y GuiX := X-30 GuiY := Y-30 Gui, Show, x%GuiX% y%GuiY% MouseClickDrag, Left,,, GuiX+3, GuiY+3, 0 MouseMove, X, Y Gui, Hide Return GuiDropFiles: ClipBoard := A_GuiControlEvent Return
Run the above code and with Winkey down, Left click on a file. The file's fullpath will be copied to the clipboard. If multiple files were selected, Clipboard will contain the file list delimited with `n ( Linefeed)
Since the above uses Gui, Show after a click, It will not work with Start Menu (which disappears before the drag could be performed). But I am sure it worked for me in a one of my experimental variants which I unfortunately do not remember!
So, this method works almost everywhere, to be precise, everywhere where you get a right click context menu for a Iconic file.
Here is a improvised version that should go into my always-running-script!SetBatchLines, -1 SetBatchLines, 1 CoordMode, Mouse, Screen CoordMode, Tooltip, Screen Menu, Tray, Icon, Clipbrd.exe,2 Gui, +AlwaysOnTop -Caption +ToolWindow Gui, Color, EEAA99 Gui +LastFound WinSet, TransColor, EEAA99 Gui, Add, Picture, x0 y0 w32 h32 vICO1 Icon1 , Clipbrd.exe Gui, Add, Picture, x0 y0 w32 h32 vICO2 Icon2 , Clipbrd.exe Gui, Show, x0 y0 w32 h32 Hide, AHK.WE2CB.DND.GUI Return #LButton:: Loop { LBDown := GetKeyState("LButton","P") IfEqual, LBDown, 0, Break } MouseGetPos, X, Y GuiX := X-50 GuiY := Y-50 GuiControl, Show, ICO1 Gui, Show, x%GuiX% y%GuiY% MouseClickDrag, Left,,, GuiX+16, GuiY+16, 0 MouseMove, X, Y GoSub, ToolTip Return GuiDropFiles: GuiControl, HIDE, ICO2 FileFullPath := A_GuiControlEvent StringReplace, FileFullPath, FileFullPath, `n,`n, All UseErrorLevel If (ErrorLevel < 1) { StringRight, Extn, FileFullPath, 3 StringUpper, Extn, Extn [color=brown] IfEqual,Extn,LNK, FileGetShortcut,%FileFullPath%, FileFullPath IfEqual,Extn,URL, IniRead,FileFullPath,%FileFullPath%,InternetShortCut,URL[/color] } Clipboard := FileFullPath Return ToolTip: SetTimer, ToolTip, Off ToolTip, % ClipBoard, GuiX+37, GuiY+6 Loop { WinKeyDown := GetKeyState("LWin","P") IfEqual, WinKeyDown, 0, Break } ToolTip GuiControl, Show, ICO2 Gui, Hide Return
Run the code. Press Windows Key and without releasing it left-click on an icon. The clipboard data will be shown as a tooltip as long as the Windows key is held down. For Quick Launch icons ( and other shotcuts too ), the actual path to the target file is retrieved.
Snapshots:
Retrieving the Target file from Quick Launch Icon
Retrieving fullpath from Windows Explorer List View
Retrieving fullpath from Windows Explorer TreeView
What really excites me is the fact that we do not have to mess with registry for defining context menus anymore.
8)
Perform Hash sum calculation for a file, calling it from a simulated context menu
Snapshots of the result:
This script requires hashes.dll to be present in the script's folder. You have to download hashes_dll.zip [45k] and extract hashes.dll from it.. Run the following script and Left-Click on a file with Winkey as a modifier:SetBatchLines, -1 SetBatchLines, 1 SetWorkingDir, %A_ScriptDir% CoordMode, Mouse, Screen Hs:="MD2|MD4|MD5||SHA1|SHA256|SHA384|SHA512||HAVAL128|HAVAL160|HAVAL192|HAVAL224|" . "HAVAL256||GHOST||TIGER128|TIGER160|TIGER192||RIPE-MD128|RIPE-MD160||CRC32|CRC16" Loop, PARSE, Hs, | Menu, HashesMenu, Add, %A_LoopField%, CalculateHash Gui, +AlwaysOnTop -Caption +Border +ToolWindow Gui, Show, x0 y0 w9 h9 Hide, AHK.WE2CB.DND.GUI Return #LButton:: MouseGetPos, X, Y GuiX := X-50 GuiY := Y-50 Gui, Show, x%GuiX% y%GuiY% MouseClickDrag, Left,,, GuiX+5, GuiY+5, 0 Return GuiDropFiles: Gui, Show, Hide MouseMove, X, Y FileFullPath := A_GuiControlEvent StringSplit, MFile, FileFullPath, `n Menu, HashesMenu, Show Return CalculateHash: Hash := DllCall("hashes.dll\testit", Str,MFile1, Str,A_ThisMenuItem, Int,0, Str) StringTrimRight, Hash, Hash, 68 SplitPath, MFile1, FileName MsgBox,4100,%MFile1%, % A_ThisMenuItem ": " Hash "`n`nCOPY hash to Clipboard?", 10 IfMsgBox, Yes, SetEnv, ClipBoard, %Hash% Return









