Page 1 of 3

4 options to change the current folder in Windows Explorer

Posted: 04 Nov 2013, 23:49
by JnLlnd
Can I ask for your help? Working on a AHK project where I need to change the current folder in Windows Explorer, I found various methods to achieve this.

Some of them were not working on my system. For one, I found that the language version of my Windows 7 was in cause. Namely, the Alt-D shortcut to focus on the address bar in Windows Explorer is known to be buggy in French locale.

With the help of chaz and using a script from rbrtryn on the old forum, I scripted various approaches to change the folder. One of them (from rbtryn) was coded specifically for WinXP (but, on my XP system, all methods work equally well).

You will find it in the script below with some debugging code. If you have 5 minutes, could you run this piece of code and paste the resulting log file (5 lines) in this thread? This will help identify the most reliable options. Special request to users of other language versions than English: you can help find if other locale has problem with the Alt-D shortcut.

Thanks!

Code: [Select all] [Expand] [Download] (ExplorerChangeFolder2.ahk)GeSHi © Codebox Plus



2013-11-05 Edited v2 with fifth method from LearningOne.
2013-11-06 Removed method Alt-D.

Re: 4 options to change the current folder in Windows Explor

Posted: 04 Nov 2013, 23:58
by JnLlnd
My results.

On XP:

Code: [Select all] [Download] (XP.log)GeSHi © Codebox Plus

Test_Name | Test_Result | A_AhkVersion | A_OSVersion | A_Is64bitOS | A_Language
Explorer_CtrlSendXP | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Explorer_F4Esc | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Explorer_AltD | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Explorer_CtrlSend | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Notepad_ControlSend | 1 | 1.1.09.02 | WIN_XP | 0 | 040C


On Win7:

Code: [Select all] [Download] (Win7.log)GeSHi © Codebox Plus

Test_Name | Test_Result | A_AhkVersion | A_OSVersion | A_Is64bitOS | A_Language
Explorer_F4Esc | 1 | 1.1.13.00 | WIN_7 | 1 | 040C
Explorer_AltD | 0 | 1.1.13.00 | WIN_7 | 1 | 040C
Explorer_CtrlSend | 1 | 1.1.13.00 | WIN_7 | 1 | 040C
Notepad_ControlSend | 1 | 1.1.13.00 | WIN_7 | 1 | 040C

Re: 4 options to change the current folder in Windows Explor

Posted: 05 Nov 2013, 00:15
by gregster
Here you go. But I should say, that I have QTTabBar ( http://sourceforge.net/projects/qttabbar/ ) installed on my system which changes the explorer a bit (multiple tabs etc.). Don't know if it makes a difference in this case...

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

Test_Name | Test_Result | A_AhkVersion | A_OSVersion | A_Is64bitOS | A_Language
Explorer_F4Esc | 1 | 1.1.13.01 | WIN_VISTA | 0 | 0407
Explorer_AltD | 0 | 1.1.13.01 | WIN_VISTA | 0 | 0407
Explorer_CtrlSend | 1 | 1.1.13.01 | WIN_VISTA | 0 | 0407
Notepad_ControlSend | 0 | 1.1.13.01 | WIN_VISTA | 0 | 0407

On multiple runs, the last two methods didn't act consistently. Sometimes they work, sometimes not. Only the first one worked every time for me.

Re: 4 options to change the current folder in Windows Explor

Posted: 05 Nov 2013, 08:25
by JnLlnd
Thank you gregster. In theory ControlSend would be the best solution but, in real life, I found it less reliable with Explorer. However, I never had problem with ControlSend in standard Dialog boxes as you did (not consistently). I also take note that Alt-D did not work with your German Windows (0407).

Re: 4 options to change the current folder in Windows Explor

Posted: 05 Nov 2013, 09:39
by gregster
Hi JnLInd,
well, it wasn't really surprising to me that Alt-D didn't work on my german Vista version, because this key combo is reserved in most german language program versions for the main application menu, called 'Datei' (I think, it's called 'File' in english apps). I don't know any replacement for that hotkey, either, on german windows.

But there seems to be some problem with your test script on my windows version, anyway.
The last two methods might be affected by the Alt-D method going rogue. My last run showed:

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

Explorer_CtrlSend | 0 | 1.1.13.01 | WIN_VISTA | 0 | 0407
Notepad_ControlSend | 1 | 1.1.13.01 | WIN_VISTA | 0 | 0407

But... in this case the Alt-D method made my Explorer window disappear completely (probably closed, not sure yet, 'Alt-D' and then 'c' would close the explorer on german windows ;) ). So, there was no explorer window anyway, when the Explorer_CtrlSend method was used this time (this happens on most runs). The explorer now came back for the Notepad_ControlSend method.
I will try to take a closer look this evening - I might have to take out the Alt-D method for good results with the last two methods.
Still, there might be an issue with the mentioned explorer extension, but I suspect the Alt-D...

Re: 4 options to change the current folder in Windows Explor

Posted: 05 Nov 2013, 11:35
by Learning one
... working on a AHK project where I need to change the current folder in Windows Explorer ...

Try this ;) :

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus


Re: 4 options to change the current folder in Windows Explor

Posted: 05 Nov 2013, 17:09
by gregster
Ok, the Alt-D part messed up the whole test script on german windows. When commented out, I got

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

Explorer_F4Esc | 1 | 1.1.13.01 | WIN_VISTA | 0 | 0407
Explorer_CtrlSend | 1 | 1.1.13.01 | WIN_VISTA | 0 | 0407
Notepad_ControlSend | 1 | 1.1.13.01 | WIN_VISTA | 0 | 0407
on a regular basis. In 5 runs, only the Notepad_ControlSend method failed once, all others times, all three methods worked.

LearningOne's suggestion was also very reliable and fast (on the active window obviously). I was already wondering if you could use a Shell object via COM...

Re: 4 options to change the current folder in Windows Explor

Posted: 05 Nov 2013, 18:14
by JnLlnd
@LearningOne: Good stuff. I added this to the test script in the original post if more people want to run it. It worked well on my 2 systems (XP and Win7). Here are my new results.

On XP:

Code: [Select all] [Download] (XP.log)GeSHi © Codebox Plus

Test_Name | Test_Result | A_AhkVersion | A_OSVersion | A_Is64bitOS | A_Language
Explorer_CtrlSendXP | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Explorer_F4Esc | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Explorer_AltD | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Explorer_CtrlSend | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Explorer_Shell | 1 | 1.1.09.02 | WIN_XP | 0 | 040C
Notepad_ControlSend | 1 | 1.1.09.02 | WIN_XP | 0 | 040C


On Win7:

Code: [Select all] [Download] (Win7.log)GeSHi © Codebox Plus

Test_Name | Test_Result | A_AhkVersion | A_OSVersion | A_Is64bitOS | A_Language
Explorer_F4Esc | 1 | 1.1.13.00 | WIN_7 | 1 | 040C
Explorer_AltD | 0 | 1.1.13.00 | WIN_7 | 1 | 040C
Explorer_CtrlSend | 1 | 1.1.13.00 | WIN_7 | 1 | 040C
Explorer_Shell | 1 | 1.1.13.00 | WIN_7 | 1 | 040C
Notepad_ControlSend | 1 | 1.1.13.00 | WIN_7 | 1 | 040C


@gregster: The Notepad_ControlSend does not work on each run for me too. Also, I removed the Ald-D method froim the script if the user language is German.

@LearningOne: Is the Shell method can be used to change folder inside standard dialog boxes (class #32770) ?

Re: 4 options to change the current folder in Windows Explor

Posted: 06 Nov 2013, 02:10
by Learning one
Hi JnLlnd,

here are my test results;

Code: [Select all] [Download] (Script.ahk)GeSHi © Codebox Plus

Test_Name | Test_Result | A_AhkVersion | A_OSVersion | A_Is64bitOS | A_Language
Explorer_F4Esc | 1 | 1.1.13.01 | WIN_7 | 1 | 041A
Explorer_AltD | 0 | 1.1.13.01 | WIN_7 | 1 | 041A
Explorer_CtrlSend | 1 | 1.1.13.01 | WIN_7 | 1 | 041A
Explorer_Shell | 1 | 1.1.13.01 | WIN_7 | 1 | 041A
Notepad_ControlSend | 1 | 1.1.13.01 | WIN_7 | 1 | 041A
Alt-D method is a bad choice. For example, in Croatian version of Windows 7, it opens Datoteka menu - translated to english: File menu.
Shell method can't be used to change folder inside standard dialog boxes (class #32770).

FYI, a few years ago, I developed a system which navigates to specified folders in Windows explorer, My Computer, standard dialog boxes (class #32770), and even in some not-standard dialog boxes.

It's called Navigator and it's part of Radial menu v4. By default, it's activated by dragging up with RButton.
If you want, I can extract relevant code from Radial menu which runs Navigator component and post it here.

Re: 4 options to change the current folder in Windows Explor

Posted: 06 Nov 2013, 08:18
by JnLlnd
I removed the Alt-D method from the test script.

LearningOne wrote:If you want, I can extract relevant code from Radial menu which runs Navigator component and post it here.


Yes, it would be really appreciated.

Re: 4 options to change the current folder in Windows Explor

Posted: 06 Nov 2013, 16:08
by timeFlies
Wow! I haven't had an opportunity to run this, but it looks like LearningOne has a good solution. This was really the only unreliable part in that FavouriteFolders script by rbrtryn.

Re: 4 options to change the current folder in Windows Explor

Posted: 06 Nov 2013, 16:16
by timeFlies
LearningOne wrote:
... working on a AHK project where I need to change the current folder in Windows Explorer ...

Try this ;) :

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus



One question: does this method work to navigate to special folders like "My Computer", "Recycle Bin", or "Control Panel"?

Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 03:55
by Learning one
@JnLlnd: Ok, I'll do it, probably within next 6 hours... ;)
@chaz: Improved version below supports navigation to special folders. ;) For more info see ShellSpecialFolderConstants enumeration.

Code: [Select all] [Expand] [Download] (Script.ahk)GeSHi © Codebox Plus


Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 07:06
by timeFlies
My results:

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

Test_Name 	       | Test_Result | A_AhkVersion | A_OSVersion | A_Is64bitOS | A_Language
Explorer_F4Esc | 1 | 1.1.10.01 | WIN_7 | 1 | 0409
Explorer_CtrlSend | 1 | 1.1.10.01 | WIN_7 | 1 | 0409
Explorer_Shell | 1 | 1.1.10.01 | WIN_7 | 1 | 0409
Notepad_ControlSend | 1 | 1.1.10.01 | WIN_7 | 1 | 0409

Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 09:13
by Learning one
JnLlnd, here's extracted code from Radial menu which runs Navigator. I haven't implemented Explorer_Navigate() function it Navigator codes yet.

Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 13:34
by JnLlnd
LearningOne wrote:JnLlnd, here's extracted code from Radial menu which runs Navigator. I haven't implemented Explorer_Navigate() function it Navigator codes yet.


Very interesting. If I understand well, you would replace the part of this code related to Explorer (ExploreWClass,CabinetWClass) with Explorer_Navigate. But the rest is still the best way you found for Dialog boxes. BTW, it looks like you put many hours of trial/error on this! Thanks for sharing :-)

Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 13:43
by JnLlnd
@LearningOne: have you tested this with Win_8?

If not, it would be nice if a Win_8 user could give a try to your code (replacing line 43 with "if A_OSVersion in WIN_8,WIN_7,WIN_VISTA").

Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 14:58
by Learning one
If I understand well, you would replace the part of this code related to Explorer (ExploreWClass,CabinetWClass) with Explorer_Navigate
Yes.
looks like you put many hours of trial/error on this! Thanks for sharing
True. Thanks.
have you tested this with Win_8
I don't have opportunity to test anything on Win_8. :(
Do you have opportunity to do tests on Win_8?

* * *

I'm currently upgrading this "Navigator system". It will now use "Explorer_Shell" method and won't depend on "if A_OSVersion in WIN_8,WIN_7,WIN_VISTA".
It will be probably finished tomorrow and I'll post it here for testing... ;)

Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 15:20
by JnLlnd
Great! Unfortunately, I can't test on Win_8 myself either... Hopefully, someone else on the forum will be?

Re: 4 options to change the current folder in Windows Explor

Posted: 07 Nov 2013, 20:31
by timeFlies
JnLlnd wrote:Great! Unfortunately, I can't test on Win_8 myself either... Hopefully, someone else on the forum will be?


I have Windows 8 installed on my computer alongside Windows 7, but I never use it. I prefer Windows 7, and it's such a pain to close all my programmes and switch OSs. Unfortunately, I have no time to run the test right now since I already expect to be up all night finishing an assignment... ooh, I hate procrastination... my fault. Maybe in a few days.