Jump to content

Creating new windows explorer window


Recommended Posts

Another Method:

Local $dirPath = "c:\WINDOWS\system32"
If Not FileExists($dirPath) Then
      MsgBox(0, "Explorer Open - Error", "Directory does not exist: "&$dirPath)
      Exit
EndIf
$oShell = ObjCreate("shell.application") 
$oShell.open($dirPath)
;OR $oShell.explore($dirPath); this will get the explorerbar to open with the Folders toolbar

If you're interested in control it once it's opened

Local $dirPath = "c:\WINDOWS\system32"
If Not FileExists($dirPath) Then
      MsgBox(0, "Explorer Open - Error", "Directory does not exist: "&$dirPath)
      Exit
EndIf
$oShell = ObjCreate("shell.application") 
Local $oShellWindows = $oShell.windows
Local $currentTotal = $oShell.windows.count;First get the current explorer window count
Local $PreviousBound = $currentTotal-1;Used later
$oShell.open($dirPath);Open new
$PreviousBound +=1
        While 1;This will give it time to open (if you don't do this it will error out)
            Local $currentTotal = $oShell.windows.count
            ConsoleWrite('$currentTotal: '&$currentTotal & ' vs '&($PreviousBound+1)&@LF)
            If  $currentTotal = ($PreviousBound+1) Then
                ExitLoop
            EndIf           
            Sleep(100)          
        WEnd
Local $Window = $oShell.windows.item($PreviousBound)
Local $WindowHwnd = HWnd($window.HWnd());NOW you have the Handler for the new Explorer Window
; Examples for manipulation to the new Explorer Window
WinSetTitle($WindowHwnd,'','New Window')


MsgBox(0,'Explorer Command','Navigation to C:\ will take place in five seconds or on ok.',5)
$window.Navigate('C:\'); Notice how with the COM commands you don't use the HWnd
A decision is a powerful thing
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...