Jumping to file explorer drives in win10

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
amz67
Posts: 19
Joined: 08 Dec 2016, 16:26

Jumping to file explorer drives in win10

21 Dec 2017, 22:07

On my win7 computer, I have commands like

#z::winActivate Z:

where Z is a mapped network drive.

That way, I can have separate file explorer windows for each mapped network drive and I can jump quickly back and forth between different drives. This works regardless of whether I am at the top of the drive or in any folder or subfolder.

In win10, this works only if I am at the top of the drive. If I go into a folder or subfolder, the folder name shows at the top of the window, not the drive, which I assume is the problem (although the file explorer window in Win7 doesn't show the Z at any time).

For someone not terribly versed in Autohotkey, can anyone suggest a solution?
User avatar
divanebaba
Posts: 813
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Jumping to file explorer drives in win10

21 Dec 2017, 22:16

Einfach nur ein toller Typ. :mrgreen:
amz67
Posts: 19
Joined: 08 Dec 2016, 16:26

Re: Jumping to file explorer drives in win10

22 Dec 2017, 16:23

Mode 2. Doesn't help, because the drive letter isn't appearing in the title at all, once I go down a level into a folder..
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Jumping to file explorer drives in win10

22 Dec 2017, 16:32

You've to configure to show the "full path" at Explorer's settings.
qwerty12
Posts: 468
Joined: 04 Mar 2016, 04:33
Contact:

Re: Jumping to file explorer drives in win10

22 Dec 2017, 16:37

divanebaba and BoBo's way is the easiest, and quicker than this:

Code: Select all

#NoEnv  ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn  ; Enable warnings to assist with detecting common errors.
SendMode Input  ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir%  ; Ensures a consistent starting directory.

#z::
getExplorerWindowPath(jumpTo := "Z:")
{
	static IID_IShellFolder, STRRET, path, SIGDN_FILESYSPATH := 0x80058000
	if (!VarSetCapacity(IID_IShellFolder))
		VarSetCapacity(IID_IShellFolder, 16), DllCall("ole32\CLSIDFromString", "WStr", "{000214E6-0000-0000-C000-000000000046}", "Ptr", &IID_IShellFolder)
		,VarSetCapacity(STRRET, 272), VarSetCapacity(path, 262 * (!!A_IsUnicode + 1))

	shellWindows := ComObjCreate("Shell.Application").Windows
	for window in shellWindows {
		try {
			isp := ComObjQuery(window, "{6d5140c1-7436-11ce-8034-00aa006009fa}")
			tlb := ComObjQuery(isp, "{4C96BE40-915C-11CF-99D3-00AA004AE837}", "{000214E2-0000-0000-C000-000000000046}")
			if (DllCall(NumGet(NumGet(tlb+0)+15*A_PtrSize), "Ptr", tlb, "Ptr*", isv) < 0)
				throw
			ifv := ComObjQuery(isv, "{cde725b0-ccc9-4519-917e-325d72fab4ce}")
			if (DllCall(NumGet(NumGet(ifv+0)+5*A_PtrSize), "Ptr", ifv, "Ptr", &IID_IShellFolder, "Ptr*", isf) < 0)
				throw
			if (DllCall(NumGet(NumGet(isf+0)+11*A_PtrSize), "Ptr", isf, "Ptr", 0, "UInt", SIGDN_FILESYSPATH, "Ptr", &STRRET) < 0)
				throw
			if (DllCall("shlwapi\StrRetToBuf", "Ptr", &STRRET, "Ptr", 0, "Str", path, "UInt", 260))
				throw
			if (SubStr(path, 1, 2) = jumpTo) {
				WinActivate % "ahk_id " . window.hwnd
				return
			}
		} catch {
			return
		} finally {
			for _, obj in [isf, ifv, isv, tlb, isp]
				if (obj)
					ObjRelease(obj)
		}
	}
}
User avatar
jeeswg
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

Re: Jumping to file explorer drives in win10

22 Dec 2017, 17:15

Try this:

Code: Select all

;[based on JEE_ExpListOpenDirs]
;Explorer window interaction (folder windows/Desktop, file/folder enumeration/selection/navigation/creation) - AutoHotkey Community
;https://autohotkey.com/boards/viewtopic.php?f=6&t=35041

;c::
;e::
#z::
vDrive := SubStr(A_ThisHotkey, StrLen(A_ThisHotkey))
hWnd := 0
for oWin in ComObjCreate("Shell.Application").Windows
	if (oWin.Name = "Windows Explorer")
	&& (oWin.Document.Folder.Self.Path = vDrive ":\") ;e.g. C:\
	;&& (SubStr(oWin.Document.Folder.Self.Path, 1, 1) = vDrive) ;e.g. starts with C
	{
		hWnd := oWin.HWND
		break
	}
oWin := ""
if hWnd
	WinActivate, % "ahk_id " hWnd
return
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
lexikos
Posts: 9635
Joined: 30 Sep 2013, 04:07
Contact:

Re: Jumping to file explorer drives in win10

23 Dec 2017, 04:32

This works for me,
with drive C and G.

Code: Select all

#c::
#g::
    drv := format("{:U}", SubStr(A_ThisHotkey, 0))
    WinActivate ahk_class CabinetWClass, Address: %drv%:\
return

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: No registered users and 92 guests