How to navigate to next sibling folder from Windows Explorer?
Re: How to navigate to next sibling folder from Windows Explorer?
Jeeswg --> With your script, I just go in the parent folder, then stop ! No good ! No good !
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
JoPo wrote:I would like, is a script that would allow me to go int the previous / next folder, if the parent folder is alone, go in the next parent folder and repeat the same untill to find a folder amonst others and directly going into it.
Code: Select all
#If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass")
^PgUp::
^PgDn:: NavigateToSiblingDir( InStr(A_ThisHotkey, "Up") )
NavigateToSiblingDir(UpDown) {
oShell := ComObjCreate("Shell.Application")
WinGet, hWnd,, A
for oWin in oShell.Windows {
if (hWnd = oWin.hwnd) {
oFolder := oWin.Document.Folder
startDirPath := oFolder.Self.Path
parentDirPath := oFolder.ParentFolder.Self.Path
break
}
}
while parentDirPath {
for item in oShell.Namespace(parentDirPath).Items {
if !item.IsFolder
continue
if (found && nextSiblingPath := item.Path)
break
if (item.Path = startDirPath && found := true)
prevSiblingPath := prev
prev := item.Path
}
if (prevSiblingPath || nextSiblingPath)
break
oFolder := oFolder.ParentFolder
startDirPath := oFolder.Self.Path
parentDirPath := oFolder.ParentFolder.Self.Path
flag := true, found := prev := ""
}
(flag && prevSiblingPath := nextSiblingPath := oFolder.Self.Path)
( (UpDown && (navigatePath := prevSiblingPath)) || (!UpDown && (navigatePath := nextSiblingPath)) )
if navigatePath {
DllCall("shell32\SHParseDisplayName", WStr, navigatePath, Ptr,0, PtrP,vPIDL, UInt,0, Ptr,0)
VarSetCapacity(SAFEARRAY, A_PtrSize=8?32:24, 0)
NumPut(1, &SAFEARRAY, 0, "UShort") ;cDims
NumPut(1, &SAFEARRAY, 4, "UInt") ;cbElements
NumPut(vPIDL, &SAFEARRAY, A_PtrSize=8?16:12, "Ptr") ;pvData
NumPut(DllCall("shell32\ILGetSize", Ptr,vPIDL, UInt), &SAFEARRAY, A_PtrSize=8?24:16, "Int") ;rgsabound[1]
oWin.Navigate2(ComObject(0x2011,&SAFEARRAY), 0)
DllCall("shell32\ILFree", Ptr,vPIDL)
}
}
I'm not sure if I understand what you mean. If the next sibling has many subfolders, which subfolder should the script navigate into?JoPo wrote:I gonna add some difficulty... Eh eh... If the script would allow me to do what I explained + going in the next / previous sibling folder untill it reaches the latest folder (in which there are only files = no more folder to continue to go in) , it would be like heaven !!
Re: How to navigate to next sibling folder from Windows Explorer?
Ah ah ! Good question ! Only the first one, then the script can go to the following one, etc. Untill the last one and next key stroke, plaf ! It goes in the parent again untill it finds the first one with siblings... Like that, you'll explore all the folders one by one, deeply with just one key stroke.
I don't know if it's possible...
I don't know if it's possible...
Re: How to navigate to next sibling folder from Windows Explorer?
Ah... It certainly means that it's not possible. Thanks anyway for your help !
-
- Posts: 1
- Joined: 27 Oct 2020, 15:58
Re: How to navigate to next sibling folder from Windows Explorer?
Sorry to bring up this old tread. But can someone help me get this working with the "Save As" window to navigate the same way as this code works with Windows Explorer?
It works great when I'm using it in Windows Explorer, but I need the same functionality when saving a file in Photoshop. Being able to use ctrl-PgUp or PgDown to flip to the sibling folder when saving would be extremely helpful. Thanks so much!
It works great when I'm using it in Windows Explorer, but I need the same functionality when saving a file in Photoshop. Being able to use ctrl-PgUp or PgDown to flip to the sibling folder when saving would be extremely helpful. Thanks so much!
Code: Select all
; navigate to next sibling folder from Windows Explorer
#If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass")
^PgUp::
^PgDn:: NavigateToSiblingDir( InStr(A_ThisHotkey, "Up") )
NavigateToSiblingDir(UpDown) {
oShell := ComObjCreate("Shell.Application")
WinGet, hWnd,, A
for oWin in oShell.Windows {
if (hWnd = oWin.hwnd) {
oFolder := oWin.Document.Folder
startDirPath := oFolder.Self.Path
parentDirPath := oFolder.ParentFolder.Self.Path
break
}
}
for item in oShell.Namespace(parentDirPath).Items {
if !item.IsFolder
continue
if (found && nextSiblingPath := item.Path)
break
if (item.Path = startDirPath && found := true)
prevSiblingPath := prev
prev := item.Path
}
if (UpDown && prevSiblingPath)
oWin.Navigate(prevSiblingPath)
if (!UpDown && nextSiblingPath)
oWin.Navigate(nextSiblingPath)
}
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: How to navigate to next sibling folder from Windows Explorer?
Can't get this to work when I replace ^PgUp and ^PgDn with XButton1 & LButton and XButton1 & RButton respectively. It keeps navigating to the next sibling folder with both hotkeys. Any ideas?
I'm talking about the code on the first page by jeeswg, really nice script otherwise
I'm talking about the code on the first page by jeeswg, really nice script otherwise
Last edited by koolestani on 20 Oct 2021, 12:33, edited 1 time in total.
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
I suppose the issue is here: vGetNext := !!InStr(A_ThisHotkey, "Dn").
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: How to navigate to next sibling folder from Windows Explorer?
i'm sorry i don't get it, where exactly you are suggesting me to insert vGetNext := !!InStr(A_ThisHotkey, "Dn") ?
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
Try to understand what this line does:
Code: Select all
^PgUp:: MsgBox, % vGetNext := !!InStr(A_ThisHotkey, "Dn")
^PgDn:: MsgBox, % vGetNext := !!InStr(A_ThisHotkey, "Dn")
XButton1 & LButton:: MsgBox, % vGetNext := !!InStr(A_ThisHotkey, "Dn")
XButton1 & RButton:: MsgBox, % vGetNext := !!InStr(A_ThisHotkey, "Dn")
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: How to navigate to next sibling folder from Windows Explorer?
i should've probably mentioned this, i'm a noob in ahk, i tried adding this code you suggested, in the existing script and of course i couldn't make it work. All i get is dialog box with the message 0
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
But I didn't suggest adding this code. I suggest to understand what the difference is between the initial pair of hotkeys and those you want to implement.koolestani wrote: ↑i tried adding this code you suggested
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: How to navigate to next sibling folder from Windows Explorer?
ahh my bad, can you please elaborate on the difference for me.
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
Just launch this script, press all the hotkeys one by one and see what message boxes will show.
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: How to navigate to next sibling folder from Windows Explorer?
i see, upon pressing
^PgUp results in 0
^PgDn results in 1
but
XButton1 & LButton results in 0
XButton1 & RButton results in 0
it's very weird that this is happening, but it explains why the script you posted on the first page isn't working for me. any tips?
^PgUp results in 0
^PgDn results in 1
but
XButton1 & LButton results in 0
XButton1 & RButton results in 0
it's very weird that this is happening, but it explains why the script you posted on the first page isn't working for me. any tips?
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
See in docs what the InStr() function does, think how to change its call to get XButton1 & RButton returning 1.koolestani wrote: ↑it's very weird that this is happening
-
- Posts: 78
- Joined: 15 Jun 2020, 04:22
Re: How to navigate to next sibling folder from Windows Explorer?
thanks for the help, i read up about the InStr() function and made the following changes and it worked
^PgUp::
^PgDn:: NavigateToSiblingDir( InStr(A_ThisHotkey, "Up") )
XButton1 & LButton::
XButton1 & RButton:: NavigateToSiblingDir( InStr(A_ThisHotkey, "L") )
^PgUp::
^PgDn:: NavigateToSiblingDir( InStr(A_ThisHotkey, "Up") )
XButton1 & LButton::
XButton1 & RButton:: NavigateToSiblingDir( InStr(A_ThisHotkey, "L") )
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
How make it work in save / Open / Save As Window i.e. ahk_class #32770
teadrinker wrote: ↑19 Nov 2017, 15:35It's a bit confusing.
For me this works:Code: Select all
#If WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass") ^PgUp:: ^PgDn:: NavigateToSiblingDir( InStr(A_ThisHotkey, "Up") ) NavigateToSiblingDir(UpDown) { oShell := ComObjCreate("Shell.Application") WinGet, hWnd,, A for oWin in oShell.Windows { if (hWnd = oWin.hwnd) { oFolder := oWin.Document.Folder startDirPath := oFolder.Self.Path parentDirPath := oFolder.ParentFolder.Self.Path break } } for item in oShell.Namespace(parentDirPath).Items { if !item.IsFolder continue if (found && nextSiblingPath := item.Path) break if (item.Path = startDirPath && found := true) prevSiblingPath := prev prev := item.Path } if (UpDown && prevSiblingPath) oWin.Navigate(prevSiblingPath) if (!UpDown && nextSiblingPath) oWin.Navigate(nextSiblingPath) }
Re: How to navigate to next sibling folder from Windows Explorer?
How to make it work in Save, Save As & Open Window i.e. ahk_class #32770 ????
Kindly help
Kindly help
-
- Posts: 4391
- Joined: 29 Mar 2015, 09:41
- Contact:
Re: How to navigate to next sibling folder from Windows Explorer?
These windows are not shell windows, this code won't work with them.