Code: Select all
F1::
If (WinActive("ahk_class CabinetWClass") || WinActive("ahk_class ExploreWClass"))
; Do something
Return
Here are excerpts from the old thread from 2009:
So, it seems ExplorerWClass could be removed from newer scripts?sinkfaze
It has to do with Microsoft's distinction between a directory being explored (ExploreWClass) and being opened (CabinetWClass). I practically tore my hair out for about a month while I was trying to figure out why I couldn't use my hotkeys consistently to sort my music files in a certain directory because the class of the window would change between those two even though the title stayed the same.
Here's an example (albeit shaky). If you create a new My Computer window using Win+E, that is really a command to explore My Computer, thus the window will be ExploreWClass. However if you were to use the AHK command to create a new My Computer window:
That is a command to open My Computer, so the window will instead be CabinetWClass.Code: Select all
Run ::{20d04fe0-3aea-1069-a2d8-08002b30309d}
Now if you want things to get really funky, use Win+E to "explore" My Computer, check the class: ExploreWClass. Then right-click a drive/folder and select Open. Check the class again: CabinetWClass! Right-click a folder inside of there and select Explore, it becomes ExploreWClass again!
kli6891
I just pressed win+e, but window spy still shows CabinetWClass. Perhaps MS changed something in Windows 7?
sinkfaze
Could be, I did fail to mention that I was using Windows XP.