-
Get the folders opened in explorer.exe
Maybe this is a thousand already asked question but i can't find anything (even in big G).
Anyway, my purpose is to get the paths opened of all the explorer.exe windows.
If there isn't a simple way could you please give me some links about reading infos from other process?
Since now I figured that the class of every explorer windows is CabinetWClass (am i wrong?) so using it with FindWindow could be a start (or not?^^)
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by Enrorr
Since now I figured that the class of every explorer windows is CabinetWClass (am i wrong?) so using it with FindWindow could be a start (or not?^^)
Are you sure? Which window do you mean: mainframe, splitter, view, tool-/re-/statusbar, ...? :confused:
Which OS are you using? I couldn't find such a window class in Windows Explorer app in my WinXP SP2.
And I am not sure this class (if already exists in some version) will be used in the next versions and was used in all the previous ones.
And BTW, are you going to consider all GetOpenFileName/GetSaveFileName dialogs too?
-
Re: Get the folders opened in explorer.exe
I'm running XP service pack 2 and explorer windows have the CabinetWClass classname.
So you could enumerate those windows, look for SysListView32 (or ComboBox) elements inside it and query those.
-
Re: Get the folders opened in explorer.exe
My Windows Explorer mainframe window has the "ExploreWClass" class name. :cool:
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by VictorN
Are you sure? Which window do you mean: mainframe, splitter, view, tool-/re-/statusbar, ...? :confused:
mainframe
Quote:
Which OS are you using? I couldn't find such a window class in Windows Explorer app in my WinXP SP2.
winXP SP3
Quote:
And BTW, are you going to consider all GetOpenFileName/GetSaveFileName dialogs too?
No just the explorer mainframes
So it seems that the classes are different :confused: even in same OS?
BTW i saw this feature in some other prog and thought it was possible to replicate it.
Any furter idea?
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by Enrorr
mainframe
winXP SP3
...
So it seems that the classes are different :confused: even in same OS?
Well, in my WinXP SP3 [Version 5.1 (Build 2600-xpsp.080413-2111 : Service Pack 3)] + Internet Explorer 7 (7.0.5730.13)
windows explorer main window still has class name "ExploreWClass".
So, please, conclude yourself. :cool:
-
Re: Get the folders opened in explorer.exe
In AUTOit forums i found:
Code:
If WinActive("classname=ExploreWClass") _
Or WinActive("classname=CabinetWClass") Then
ToolTip("Explorer Window is Active")
And:
Quote:
CabinetWClass = right click on "my computer" and select open
ExploreWClass = right click on "my computer" and select explore
Make a folder on the desktop.
Double click = CabinetWClass
Make the folders show like a classic two pane view and it is still a CabinetWClass
so it seems that both classname are used in WinXP...
In a little i'm gonna test it in Vista and let you know
PS:same build of XP as me
-
Re: Get the folders opened in explorer.exe
But are you sure there are no / won't ever be any other variants for class name? :rolleyes:
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by VictorN
But are you sure there are no / won't ever be any other variants for class name? :rolleyes:
Obviously no^^
After the Vista check we'll know a bit more
-
Re: Get the folders opened in explorer.exe
What you could do is restrict the search to searching windows that are only in an Explorer.exe process. You can also help restrict the search by comparing other things like parent window (and it's class name) or perform a partial/complete class name match.
See the EnumWindows code in this post for a sample.
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by Enrorr
In AUTOit forums i found:
Quote:
CabinetWClass = right click on "my computer" and select open
ExploreWClass = right click on "my computer" and select explore
Make a folder on the desktop.
Double click = CabinetWClass
Make the folders show like a classic two pane view and it is still a CabinetWClass
Well, yes, when I open "My Computer" or "My Documents" I get "CabinetWClass", and when I open "Windows Explorer" - then 'ExploreWClass'.
And after App has started, then it doesn't ,of course, change this class name anymore, whether it uses "classic two pane view" or only one view!
-
Re: Get the folders opened in explorer.exe
Checked in VISTA:
The mainframe seems to be CabinetWClass.
So I can go on?^^
-
Re: Get the folders opened in explorer.exe
If you're trying to allow the user to pick a folder, you're on a wrong path.
Your technique can lead to many nasty surprises. The user may have lots of explorer windows opened on the desktop. He may close the explorer window you open for him.
The right approach is to use the "Browse For Folders" dialog box. The feature is provided by the Shell.
Try this code:
Code:
IMalloc __RPC_FAR* pMalloc;
if(::SHGetMalloc(&pMalloc) == NOERROR)
{
char pszPath[MAX_PATH];
BROWSEINFO bi;
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszPath;
bi.lpszTitle = _T("Select a Folder");
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
ITEMIDLIST* pIDL;
if(pIDL = ::SHBrowseForFolder(&bi))
{
if(::SHGetPathFromIDList(pIDL, pszPath))
{
MessageBox(pszPath);
}
pMalloc->Free(pIDL);
}
pMalloc->Release();
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by srelu
If you're trying to allow the user to pick a folder, you're on a wrong path.
Your technique can lead to many nasty surprises. The user may have lots of explorer windows opened on the desktop. He may close the explorer window you open for him.
The right approach is to use the "Browse For Folders" dialog box. The feature is provided by the Shell.
Try this code:
Code:
IMalloc __RPC_FAR* pMalloc;
if(::SHGetMalloc(&pMalloc) == NOERROR)
{
char pszPath[MAX_PATH];
BROWSEINFO bi;
bi.hwndOwner = GetSafeHwnd();
bi.pidlRoot = NULL;
bi.pszDisplayName = pszPath;
bi.lpszTitle = _T("Select a Folder");
bi.ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS;
bi.lpfn = NULL;
bi.lParam = 0;
ITEMIDLIST* pIDL;
if(pIDL = ::SHBrowseForFolder(&bi))
{
if(::SHGetPathFromIDList(pIDL, pszPath))
{
MessageBox(pszPath);
}
pMalloc->Free(pIDL);
}
pMalloc->Release();
I'm not doing this....
And I'm not gonna open any new window, i just want to get the path from already opened ones.
The user will have the possibility to choose if doing operation in an already open path (the one i'm stucking with) or to browse for another one with a dialog.
I just want operations to be fastest as often the folder you're working it are already opened in explorer, if not you can still browse for them ;)
-
Re: Get the folders opened in explorer.exe
What exactly are you trying to do ?
Also, how exactly is using FindWindow etc.. going to help you ?
-
Re: Get the folders opened in explorer.exe
Users need to choose where to copy file.
As I said (sorry for my bad english), he can choose if to copy in one of the folders already opened in windows explorer if any, or browse for one using a dialog (the one SHBrowseForFolder shows).
I thought that FindWindow could help me to find if there's one or more explorer windows opened, but I'm stuck here since I don't know how to get the paths.
I noticed that the can be in the combo box (the adress bar) but not everybody uses it.
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by Enrorr
Users need to choose where to copy file.
As I said (sorry for my bad english), he can choose if to copy in one of the folders already opened in windows explorer if any, or browse for one using a dialog (the one SHBrowseForFolder shows).
I thought that FindWindow could help me to find if there's one or more explorer windows opened, but I'm stuck here since I don't know how to get the paths.
I noticed that the can be in the combo box (the adress bar) but not everybody uses it.
Just use SHBrowseForFolder and call it a day. Although retrieving paths from explorer can be done reliably, there isn't much benefit to the user for doing so. Users won't expect this behavior.
If the user has an explorer window open, then can always paste in the path if they want to; otherwise they can use the Browse functionality.
-
Re: Get the folders opened in explorer.exe
I agree. As a seaoned windows users, I would NOT expect such a functionality.
-
Re: Get the folders opened in explorer.exe
I agree it's not common, but i personally found useful.
Anyway i was just curious how to take infos from other process or windows...
Do you know any reading about it?
-
Re: Get the folders opened in explorer.exe
A good start would be to look at the EnumWindows code link I posted earlier.
-
Re: Get the folders opened in explorer.exe
d'oh i totally missed it...
Thanks for the hint.
-
Re: Get the folders opened in explorer.exe
Check that out and use the Spy++ tool to understand the relationships of the windows (parent, child, grand parent, etc.). After you understand that post back, and I'll explain how you can manipulate them.
-
Re: Get the folders opened in explorer.exe
Ok I suppose I got it.
I think it will be useful to get the text of the ComboBox32 class even if it isn't visible.
I'll try for now to do it using FindWindowEx, even as I understood your function has better functionality.
EDIT: I got some results
Using FindWindowEx I got the combobox (after getting its father,grandfather,and grandgrandfather HWND), then sent a WM_GETTEXT message and i got the path.
Now I need to enumerate all explorer windows (I think your function Arjay now will come in hand)
-
Re: Get the folders opened in explorer.exe
It's a bad method.
The standard method is to use COM Interfaces (IWebBrowserApp, etc)
-
Re: Get the folders opened in explorer.exe
Quote:
Originally Posted by fred100
It's a bad method.
The standard method is to use COM Interfaces (IWebBrowserApp, etc)
Not in this case, Fred. Reread the post to find out what the OP is actually trying to do.
-
Re: Get the folders opened in explorer.exe
Greetings,
I was justing looking for this same thing, because I want to build a program that allows the users to Undo closed folders (much like Firefox's undo closed tab, but for windows), so im in the need to know the opened folders' full path
So, let me get this clear (im kinda newbie with hWnd and stuff):
I need to look through all my open windows (with EnumWindows for ex), then find those which are folders (with the Cabinet/Explorer class), and then get into the window and copy the from the combobox showing the path?
Thanks!