Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Explorer Windows Manipulations


  • Please log in to reply
99 replies to this topic
TRS80
  • Members
  • 17 posts
  • Last active: Dec 13 2009 02:41 PM
  • Joined: 11 Dec 2007
Since you are quoting me, majkinetor, I find your remarks unnecessarily insulting. I did read the script and I tried several different solutions, but they didn't work. I spent an hour searching through the documentation, trying to understand what was required to do what I wanted. I am not a programmer and this script is beyond my understanding. So yes, I can read, and did read the script, but the solution was taking far more time than I wanted to invest in using the script. So, I reluctantly asked the question which lexikos answered. Correct me if I have missed the purpose for this list or did I misinterpret your kindness?

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

I wouldn't answer to the people that can't even look at the script....

The example uses A_MyDocuments and similar built-in variables. Someone new to AutoHotkey mightn't realise:
[*: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...

TRS80
  • Members
  • 17 posts
  • Last active: Dec 13 2009 02:41 PM
  • Joined: 11 Dec 2007
lexikos: Thank you for kindly answering my questions and for pointing me in the right direction. 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. The, I searched on A_WinDir and didn't find anything helpful. I tried several combinations of A_Drivers or A_M:\Drivers but they went nowhere. I even tried M:\Drivers without the quotes and no joy.

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.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

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.

Which version of Windows are you running? I suspect it is specific to Windows XP.

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.

ShellNavigate is defined in this script (ExplorerWindowControl.ahk).

Given the way the script is written, is the single panel a default behavior or is it intentionally set up that way?

It is likely a default behaviour. I'm not sure of any way to change it with the APIs used by this script.

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.



ShellTeam
  • Guests
  • Last active:
  • Joined: --

ShellNavigate("M:\Drivers", 0x20)

It'll open a new window if not already in the explore mode.

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.



TRS80
  • Members
  • 17 posts
  • Last active: Dec 13 2009 02:41 PM
  • Joined: 11 Dec 2007
lexikos: Thank you for the additional info. I have printed it out to keep. Yes, I am running Win XP sp2.

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.

Lexikos
  • Administrators
  • 9844 posts
  • AutoHotkey Foundation
  • Last active:
  • Joined: 17 Oct 2006

ShellNavigate("M:\Drivers", 0x20)

It'll open a new window if not already in the explore mode.

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.

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:

If the current browser does not match the SBSP_EXPLOREMODE of the browse object call, a new window is opened.

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.

ShellTeam: Given this particular script, ShellNavigate("M:\Drivers") and ShellNavigate("M:\Drivers", 0x20) behave identically. See above.

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. :?

If you don't mind opening a new window, this might be an alternative:
Run, explorer.exe /e`,M:\Drivers


TRS80
  • Members
  • 17 posts
  • Last active: Dec 13 2009 02:41 PM
  • Joined: 11 Dec 2007
Hello lexikos and ShellTeam:

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
(B) 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


ShellTeam
  • Guests
  • Last active:
  • Joined: --

!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()
pwb := SHGetIDispatchForFolder(sPath)
with
Run, explorer.exe /e`,%sPath%


Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
The script is significantly simplified, now all through Dispatch interfaces.

nonov
  • Guests
  • Last active:
  • Joined: --
Hi, is it possible to modify ShellFolder() to get from the desktop too?
i've tried by adding (hwnd:=WinExist("ahk_class Progman")) to ShellFolder() but no luck :(

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

Hi, is it possible to modify ShellFolder() to get from the desktop too?

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.

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007
Here is one method. Need the latest Accessibility Standard Library.
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
}


tg2k
  • Members
  • 3 posts
  • Last active: Oct 16 2008 06:53 PM
  • Joined: 12 Aug 2007
In trying the Explorer manipulations (to get the current folder) I am getting a COM Error Notification:

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?
--Todd ( www.cool-man.org )

Sean
  • Members
  • 2462 posts
  • Last active: Feb 07 2012 04:00 AM
  • Joined: 12 Feb 2007

I see this error especially if I have a Windows Search Results window open.

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 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?

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().