Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Get current path in Explorer seems to be not working anymore


Best Answer Jackie Sztuk _Blackholyman , 13 October 2015 - 11:52 AM

Go to the full post »


  • Please log in to reply
2 replies to this topic
General Grandissmio
  • Members
  • 5 posts
  • Last active: Oct 29 2015 09:19 AM
  • Joined: 14 Mar 2015

I am using a script from Learning One, that let me get the current path of any selected file in Windows Explorer.

It worked perfectly for a long time.

F1::clipboard:= % Explorer_GetSelection()

Explorer_GetSelection(hwnd="") {
    hwnd := hwnd ? hwnd : WinExist("A")
    WinGetClass class, ahk_id %hwnd%
    if (class="CabinetWClass" or class="ExploreWClass" or class="Progman")
        for window in ComObjCreate("Shell.Application").Windows
            if (window.hwnd==hwnd)
sel := window.Document.SelectedItems
    for item in sel
    ToReturn .= item.path "`n"
    return Trim(ToReturn,"`n")
}

But now it just won't seem to be working anymore.

I am on a Win7 machine, using AHK version 1.1.22.07

 

Can anyone confirm that behavior for me?

Might it be a bug in AHK? Did Windows change?

Any help is appreciated,

thank you!

________________________________________

 

Who also might be using Q-Dir, I expanded the script to work with either Windows Explorer or Q-Dir, to get the current Path of any marked file/folder in the clipboard

F1::
IfWinActive ahk_exe Q-Dir.exe
	{
		send {AppsKey}
		sleep 10
		send {Up}{Up}{Return}
	}
IfWinActive ahk_exe explorer.exe
	{
		clipboard:= % Explorer_GetSelection()
	}
else
	{
		return
	}
return

Explorer_GetSelection(hwnd="") {
    hwnd := hwnd ? hwnd : WinExist("A")
    WinGetClass class, ahk_id %hwnd%
    if (class="CabinetWClass" or class="ExploreWClass" or class="Progman")
        for window in ComObjCreate("Shell.Application").Windows
            if (window.hwnd==hwnd)
sel := window.Document.SelectedItems
    for item in sel
    ToReturn .= item.path "`n"
    return Trim(ToReturn,"`n")
}


Jackie Sztuk _Blackholyman
  • Spam Officer
  • 3757 posts
  • Last active: Apr 03 2016 08:47 PM
  • Joined: 28 Feb 2012
✓  Best Answer
Still works fine for me on windows 7 using AHK version 1.1.22.07

Try restarting windows and make sure your script is run as Admin
Helping%20you%20learn%20autohotkey.jpg?d

[AHK] Version. 1.1+ [CLOUD] DropBox ; Copy [WEBSITE] Blog ; About

General Grandissmio
  • Members
  • 5 posts
  • Last active: Oct 29 2015 09:19 AM
  • Joined: 14 Mar 2015

thank you so much for checking (and sorry for my double-post)
Unfortunately the fancier version won't seem to work for me anymore,
but the other version Link works fine.
I will keep on looking, if I can find the reason, might be my PC probably, and will post it.