How to navigate to next sibling folder from Windows Explorer?

Get help with using AutoHotkey and its commands and hotkeys
kai
Posts: 3
Joined: 30 Aug 2017, 01:31

How to navigate to next sibling folder from Windows Explorer?

19 Nov 2017, 04:05

I am searching for a way to navigate from folder A to folder B from inside folder A:

- Top Folder
-- A (I am here)
-- B

AHK-Shortcut, then:

- Top Folder
-- A
-- B (now I am here)

Can somebody help?
User avatar
jeeswg
Posts: 3010
Joined: 19 Dec 2016, 01:58
Location: UK

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

19 Nov 2017, 10:35

Here's a way. I've been using something like this for a while, I just tidied it up now for sharing. I wonder, how many people around the world have been using a handy 'navigate to sibling folder' method before now.

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by jeeswg on 26 Nov 2017, 14:59, edited 1 time in total.
teadrinker
Posts: 303
Joined: 29 Mar 2015, 09:41

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

19 Nov 2017, 15:35

It's a bit confusing. :)
For me this works:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

kai
Posts: 3
Joined: 30 Aug 2017, 01:31

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

20 Nov 2017, 01:37

Thanks both of you!!

I tried both scripts and they work great. THIS is awesomeness!!

Note (bug): Both scripts do not jump in folders with a underline as it seems, e.g. "_files"

@teadrinker's script: Nicely short!

It is so handy and saves soooo much time! Gosh, unbelievable that I never used this in my life.

@jeeswg: Everybody should use it! It is such a simple feature but so powerful.
User avatar
jeeswg
Posts: 3010
Joined: 19 Dec 2016, 01:58
Location: UK

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

20 Nov 2017, 10:14

- On testing, I didn't see any problems with folders that contain underscore. However you can get different sort orders relating to underscore i.e. Explorer displays folders in one order, the file loop retrieves them in another.
- In this list of characters sorted by their Unicode number:
@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_
`abcdefghijklmnopqrstuvwxyz{|}~
To do a case insensitive comparison, you either convert to lowercase or uppercase, and then you do a case sensitive comparison. If you convert to uppercase as the intermediary stage, then letters are always before underscore (e.g. file loop), if you convert to lowercase as the intermediary stage, then letters are always after underscore (e.g. Explorer windows). E.g. create a folder called 'a' and a folder called '_', and compare where they appear in an Explorer window, and in a file loop.
- My script is longer because I included some code to handle folders that contain #, which you could also use in teadrinker's script.
teadrinker
Posts: 303
Joined: 29 Mar 2015, 09:41

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

20 Nov 2017, 10:34

jeeswg wrote:I included some code to handle folders that contain #
I tested my script with folders called like "#files", it works. Do I misunderstand something?
User avatar
jeeswg
Posts: 3010
Joined: 19 Dec 2016, 01:58
Location: UK

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

20 Nov 2017, 10:40

kai mentioned _, I mentioned #.

Re. #:
4 options to change the current folder in Windows Explorer - Page 3 - AutoHotkey Community
https://autohotkey.com/boards/viewtopic.php?f=5&t=526&p=16161#p16161
teadrinker
Posts: 303
Joined: 29 Mar 2015, 09:41

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

20 Nov 2017, 11:01

Thanks, I got it now. One more solution.
User avatar
jeeswg
Posts: 3010
Joined: 19 Dec 2016, 01:58
Location: UK

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

20 Nov 2017, 11:15

Your link is to reformatcode.com? What is that, a clone of the Stack Overflow link? Is the link safe?

windows - Navigate Shell command not working when the path includes an hash - Stack Overflow
https://stackoverflow.com/questions/22868546/navigate-shell-command-not-working-when-the-path-includes-an-hash

Btw vafylec's Navigate2 solution is the same as mine, our code is often very similar.
teadrinker
Posts: 303
Joined: 29 Mar 2015, 09:41

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

20 Nov 2017, 13:04

Ok, but your approach opens a new window when navigates to folder which contains "#". Some improvements:

Code: [Select all] [Expand] [Download] GeSHi © Codebox Plus

Last edited by teadrinker on 20 Nov 2017, 14:42, edited 1 time in total.
User avatar
jeeswg
Posts: 3010
Joined: 19 Dec 2016, 01:58
Location: UK

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

20 Nov 2017, 13:09

Which OS do you use? Did you change the Explorer settings? My script does not open any new windows AFAIK (tested on Windows 7).

So what have you changed, you've added navVirtualTab := 14 to Navigate2, which seems like a good idea. Anything else?
teadrinker
Posts: 303
Joined: 29 Mar 2015, 09:41

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

20 Nov 2017, 13:29

Tested on Windows 7 too. My folder path is:

Image

When I try to navigate between those folders, your script always opens a new window for me. Of course IE settings were changed for a long time using, but I don't know what exactly causes such behavior.
Anything else?
I thought, if navigate method not always works, it makes sense using navigate2 in any case.
User avatar
jeeswg
Posts: 3010
Joined: 19 Dec 2016, 01:58
Location: UK

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

26 Nov 2017, 00:48

@teadrinker:
- You specified 'navVirtualTab := 14', which is 0xE. Where did you get that figure from? Because according to ExDisp.h and:
BrowserNavConstants Enumeration
https://msdn.microsoft.com/en-us/library/dd565688(v=vs.85).aspx

Code: [Select all] [Download] GeSHi © Codebox Plus

;navNoWriteToCache := 0x8
;navNoReadFromCache := 0x4
;navNoHistory := 0x2
2|4|8 = 14 = 0xE

;navVirtualTab := 0x4000

- Could you try that script again, but specifying 0 or 2 or 4 or 8 or combinations, to see if you don't actually need 14. Thanks.
teadrinker
Posts: 303
Joined: 29 Mar 2015, 09:41

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

26 Nov 2017, 13:21

Hi, jeeswg. Yes, you are right, navVirtualTab is not 14. I looked constants here and I thought for some reason that it is a 0-based enumerator: navOpenInNewWindow = 0, navNoHistory = 1 and so on.

Now I've tested the script once again and found out that if I don't specify any flags, the script does open new windows, but if I specify 0 (as well as 2, 4, or 8), the script does not.
User avatar
jeeswg
Posts: 3010
Joined: 19 Dec 2016, 01:58
Location: UK

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

26 Nov 2017, 14:55

@teadrinker:
Many thanks, I'll change my script from:
oWin.Navigate2(ComObject(0x2011, &SAFEARRAY))
to
oWin.Navigate2(ComObject(0x2011, &SAFEARRAY), 0)
Plus, it's good to know where the number came from.
Btw it's odd these links, one has the constants, one doesn't. Hmm. :think:

Return to “Ask For Help”

Who is online

Users browsing this forum: Bing [Bot], Yahoo [Bot] and 46 guests