Explorer Windows Manipulations
The example uses A_MyDocuments and similar built-in variables. Someone new to AutoHotkey mightn't realise:I wouldn't answer to the people that can't even look at the script....
[*:28570fx8]that A_MyDocuments is a variable
[*:28570fx8]that A_MyDocuments is a built-in variable (i.e. has a pre-defined value)
[*:28570fx8]where to look to find out what A_MyDocuments contains...
I will read up on A_MyDocuments when I have time because I would like to know more about the workings of AutoHotkey.
I have experimented with the command toggle suggested earlier to get both panels in Windows Explorer to show up, but I haven't figured that out. Given the way the script is written, is the single panel a default behavior or is it intentionally set up that way?
Thanks again for your time and words of wisdom.
Which version of Windows are you running? I suspect it is specific to Windows XP.I have experimented with the command toggle suggested earlier to get both panels in Windows Explorer to show up, but I haven't figured that out.
ShellNavigate is defined in this script (ExplorerWindowControl.ahk).When I first began studying the script, I did some searching on what looked like a function called ShellNavigate and found nothing in the forums or documentation that helped.
It is likely a default behaviour. I'm not sure of any way to change it with the APIs used by this script.Given the way the script is written, is the single panel a default behavior or is it intentionally set up that way?
If you have any requests unrelated to this script (like general help with scripting), please post in the Ask for Help forum.
Edit: It was easier than I expected. ShellNavigate() accepts a parameter "nFlags", which is a bitwise combination of flags (defined at MSDN.) The one you want is SBSP_EXPLOREMODE (0x20).
ShellNavigate("M:\Drivers", 0x20)Here is a list of flags, for the curious:
#define SBSP_DEFBROWSER 0x0000 #define SBSP_SAMEBROWSER 0x0001 #define SBSP_NEWBROWSER 0x0002 #define SBSP_DEFMODE 0x0000 #define SBSP_OPENMODE 0x0010 #define SBSP_EXPLOREMODE 0x0020 #define SBSP_HELPMODE 0x0040 #define SBSP_NOTRANSFERHIST 0x0080 #define SBSP_ABSOLUTE 0x0000 #define SBSP_RELATIVE 0x1000 #define SBSP_PARENT 0x2000 #define SBSP_NAVIGATEBACK 0x4000 #define SBSP_NAVIGATEFORWARD 0x8000 #define SBSP_ALLOW_AUTONAVIGATE 0x00010000
These flags specify whether another window is to be created.
SBSP_DEFBROWSER
Use default behavior, which respects the view option (the user setting to create new windows or to browse in place). In most cases, calling applications should use this flag.
SBSP_SAMEBROWSER
Browse to another folder with the same Windows Explorer window.
SBSP_NEWBROWSER
Creates another window for the specified folder.
The following flags specify the mode. These values are ignored if SBSP_SAMEBROWSER is specified or if SBSP_DEFBROWSER is specified and the user has selected Browse In Place.
SBSP_DEFMODE
Use the current window.
SBSP_OPENMODE
Specifies no folder tree for the new browse window. If the current browser does not match the SBSP_OPENMODE of the browse object call, a new window is opened.
SBSP_EXPLOREMODE
Specifies a folder tree for the new browse window. If the current browser does not match the SBSP_EXPLOREMODE of the browse object call, a new window is opened.
SBSP_HELPMODE
Not supported. Do not use.
SBSP_NOTRANSFERHIST
Do not transfer the browsing history to the new window.
The following flags specify the category of the pidl parameter.
SBSP_ABSOLUTE
An absolute pointer to an item identifier list (PIDL), relative to the desktop.
SBSP_RELATIVE
A relative PIDL, relative to the current folder.
SBSP_PARENT
Browse the parent folder, ignore the PIDL.
SBSP_NAVIGATEBACK
Navigate back, ignore the PIDL.
SBSP_NAVIGATEFORWARD
Navigate forward, ignore the PIDL.
SBSP_ALLOW_AUTONAVIGATE
Enable auto-navigation.
It'll open a new window if not already in the explore mode.ShellNavigate("M:\Drivers", 0x20)
The following flags specify the mode. These values are ignored if SBSP_SAMEBROWSER is specified or if SBSP_DEFBROWSER is specified and the user has selected Browse In Place.
If Windows Explorer is not launched and I press the hotkey to jump to M:\Drivers, I always get a single panel display of M:\Drives no matter what. There is no tree panel (on the left side of screen). I have tried the various bitmaps you listed without success. ("M:\Drivers", 0x20), etc.
However, if Windows Explorer running and then I use the hotkey to jump to M:\Drivers, both panels remain open and useable. In this example, I can jump between A_WinDir and M:\Drivers and both panels remain open. If Windows Explorer is not running and I use the hotkey to jump to A_WinDir, there is no tree panel, just the single panel showing the contents of my Windows Directory.
ShellTeam: Given this particular script, ShellNavigate("M:\Drivers") and ShellNavigate("M:\Drivers", 0x20) behave identically. See above.
Thank you both for your help.
You are correct. However, contrary to that quote, SBSP_EXPLOREMODE is not ignored in either case, at least on Vista. A more appropriate quote would have been:It'll open a new window if not already in the explore mode.ShellNavigate("M:\Drivers", 0x20)The following flags specify the mode. These values are ignored if SBSP_SAMEBROWSER is specified or if SBSP_DEFBROWSER is specified and the user has selected Browse In Place.
If SBSP_NEWBROWSER must be specified, there would be no need for the above exception, since a new window would be opened every time. This implies that SBSP_EXPLOREMODE may in fact be used with SBSP_SAMEBROWSER or SBSP_DEFBROWSER when the user has selected Browse In Place, despite the previous quote.If the current browser does not match the SBSP_EXPLOREMODE of the browse object call, a new window is opened.
They may not behave consistently, but they certainly do not behave identically. Without 0x20 (assuming Browse In Place is the default setting), an existing window is reused. With 0x20, an existing window is reused if it is in explore mode, otherwise a new window is opened in explore mode. However, as TRS80 noted, if no windows are open, on Vista it seems to open a new window not in explore mode. :?ShellTeam: Given this particular script, ShellNavigate("M:\Drivers") and ShellNavigate("M:\Drivers", 0x20) behave identically. See above.
If you don't mind opening a new window, this might be an alternative:
Run, explorer.exe /e`,M:\Drivers
I finally figured out a way modify the Explorer script so that in XP it will:
(a) launch Explorer so that it shows both panels
( it opens to the desired folder in the treeview panel and the contents of that folder are showing in the right panel and
© if hotkeys toggle other folders, the program stays within the one instance of Explorer that was launched. (I didn't want several instances of Explorer running.)
This is what I was hoping to accomplish and I've learned something new! Of course, I don't begin to understand everything going on in the script, but thanks for your willingness to help! Here's the code. Yes, very primitive, but it works!
!d:: if winexist("ahk_class ExploreWClass") ShellNavigate("M:\Drivers", 0x0020) else Run explorer /e`, M:\Drivers return
Instead, you may simply replace the cmd in ShellNavigate()!d:: if winexist("ahk_class ExploreWClass") ShellNavigate("M:\Drivers", 0x0020) else Run explorer /e`, M:\Drivers return
pwb := SHGetIDispatchForFolder(sPath)with
Run, explorer.exe /e`,%sPath%
i've tried by adding (hwnd:=WinExist("ahk_class Progman")) to ShellFolder() but no luck
No, ShellFolder() won't work with Progman, unfortunately. AFAIK, there is no exposed interface for it. However, as it's simply a ListView (SysListView32) control, you may utilize it. Or you may use Accessibility Standard Library.Hi, is it possible to modify ShellFolder() to get from the desktop too?
MsgBox % ShellDesktop() Return ShellDesktop() { ControlGet, hWnd, hWnd,, SysListView321, ahk_class Progman Acc_Init() pacc := Acc_AccessibleObjectFromWindow(hWnd) If SubStr(penm:=acc_Selection(pacc),1,1)=" " Loop If COM_Enumerate(penm,idChild)<>0 { COM_Release(penm) Break } Else sSelect.=acc_Name(pacc,idChild) . "`n" Else If penm sSelect:=acc_Name(pacc,penm) If idChild:=acc_Focus(pacc) sFocus :=acc_Name(pacc,idChild) COM_Release(pacc) Acc_Term() Return "Focus: " . sFocus . "`n<Selected Items>`n" . sSelect }
Function Name: "Document"
ERROR: No such interface supported (0x80004002)
...
I believe that this comes from this line:
pfv := COM_Invoke(pwb, "Document")
COM_Invoke checks the returned HRESULT and pops up the error window. I see this error especially if I have a Windows Search Results window open.
(I have also had situations where the various methods return null so I have added a lot of null checks in my own code.)
I would like to handle (and ignore) the error myself, but I don't see a way to do this with the provided COM.ahk. Am I missing something? Do I need to add in another variant of this?
I completely forgot that Windows has this functionality as I don't use it. Anyway what's your OS? "Document" function worked even with Search in my XPSP3.I see this error especially if I have a Windows Search Results window open.
You can suppress the error msgbox by executing COM_Error(False). If you want to handle the error yourself, just make hr (and/or lr) Global in COM_Invoke().I would like to handle (and ignore) the error myself, but I don't see a way to do this with the provided COM.ahk. Am I missing something? Do I need to add in another variant of this?