How to navigate to next sibling folder from Windows Explorer?

Get help with using AutoHotkey and its commands and hotkeys
JoPo
Posts: 25
Joined: 04 Feb 2018, 09:03

Re: How to navigate to next sibling folder from Windows Explorer?

06 Mar 2018, 16:13

Jeeswg --> With your script, I just go in the parent folder, then stop ! No good ! No good ! :mrgreen:
> > > > > > > > > > > > --- Musica --> here ! ---< < < < < < < < < < < <
teadrinker
Posts: 387
Joined: 29 Mar 2015, 09:41
Contact:

Re: How to navigate to next sibling folder from Windows Explorer?

06 Mar 2018, 18:09

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)
   }
}
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 !! :o
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
Posts: 25
Joined: 04 Feb 2018, 09:03

Re: How to navigate to next sibling folder from Windows Explorer?

06 Mar 2018, 20:11

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...
> > > > > > > > > > > > --- Musica --> here ! ---< < < < < < < < < < < <
JoPo
Posts: 25
Joined: 04 Feb 2018, 09:03

Re: How to navigate to next sibling folder from Windows Explorer?

08 Mar 2018, 13:39

Ah... It certainly means that it's not possible. Thanks anyway for your help !
> > > > > > > > > > > > --- Musica --> here ! ---< < < < < < < < < < < <

Return to “Ask For Help”

Who is online

Users browsing this forum: gwarble, pilgrim333, Scofuz, vvhitevvizard and 48 guests