Jump to content

Is it possible to embed Windows Explorer?


Recommended Posts

I would like to embed two Windows File Explorers side by side. Can this be done? I used the example for IE Explorer, but I can't control the detail view.

#include <GUIConstants.au3>

$oWinExplorer = ObjCreate("Shell.Explorer")
; Create a simple GUI for our output
GUICreate ( "Embedded Windows Explorer Test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2, BitOr($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS, $WS_CLIPCHILDREN))
$GUIActiveX      = GUICtrlCreateObj   ( $oWinExplorer,    10, 40 , 600 , 360 )

GUISetState ()    ;Show GUI

; get file folder
$oWinExplorer.navigate("D:\Index")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()  
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
    EndSelect
Wend

GUIDelete ()
Exit

Thanks

Link to comment
Share on other sites

Look at _IECreateEmbedded in the helpfile... it might help you.

Thanks, that's the example I used. But all of that is for using the Web Browser. I want to just set something up using two Windows Explorers in its own contained window where I can use the file browsers as normal.
Link to comment
Share on other sites

Well, I messed around with it a little and you can use the _IENavigate to go through you folders to... on my computer it wasn't working perfectly but it did work. Just something like _IENavigage($webItem, 'C:\')

How do you mean? How could I fit it into the example I used? - Thanks
Link to comment
Share on other sites

@JusGellin

What he means is this :

#include <GUIConstants.au3>
#include <IE.au3>

_IEErrorHandlerRegister ()

$oIE = _IECreateEmbedded ()
GUICreate("Embedded Web control Test", 640, 580, _
        (@DesktopWidth - 640) / 2, (@DesktopHeight - 580) / 2, _
        $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$GUIActiveX = GUICtrlCreateObj($oIE, 10, 40, 600, 360)
$GUI_Button_Back = GUICtrlCreateButton("Back", 10, 420, 100, 30)
$GUI_Button_Forward = GUICtrlCreateButton("Forward", 120, 420, 100, 30)
$GUI_Button_Home = GUICtrlCreateButton("Home", 230, 420, 100, 30)
$GUI_Button_Stop = GUICtrlCreateButton("Stop", 340, 420, 100, 30)

GUISetState()       ;Show GUI

_IENavigate ($oIE, "C:\")

; Waiting for user to close the window
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $GUI_Button_Home
            _IENavigate ($oIE, "C:\")
        Case $msg = $GUI_Button_Back
            _IEAction ($oIE, "back")
        Case $msg = $GUI_Button_Forward
            _IEAction ($oIE, "forward")
        Case $msg = $GUI_Button_Stop
            _IEAction ($oIE, "stop")
    EndSelect
WEnd

regards

ptrex

Link to comment
Share on other sites

That doesn't quite do what I want. I would like to have a detailed view of the Windows Explorer, but this only gives me folders. I finally figured out how to at least get the Windows Explorer part working like I wanted, but without the embedded part:

Opt("WinTitleMatchMode", 3)
RunWait("explorer.exe /e,d:\index")
WinWait("D:\Index", "")
WinMove("D:\Index", "", 600, 0, 600, 500)

RunWait("explorer.exe /e,d:\index")
WinWait("D:\Index", "")
WinMove("D:\Index", "", 0, 0, 600, 500)

What this does is put two Windows Explorer windows side by side on the desktop. I would lke to embed these both in a window(form) so I could move the one window anywhere on my desktop to use. So, how can I embed the above code in a window, if it is possible?

Thanks again

Link to comment
Share on other sites

  • Moderators

Fun times...

#include <GUIConstants.au3>

$hGUI = GUICreate("MyExplorer", 1200, 500, -1, -1, BitOr($WS_MINIMIZEBOX, $WS_CAPTION, $WS_POPUP, $WS_SYSMENU, $WS_CLIPCHILDREN))
$Exp1 = _RunEmbExp("explorer.exe /e,d:\index", "[CLASS:ExploreWClass]", $hGUI, 600, 0, 600, 500)
$Exp2 = _RunEmbExp("explorer.exe /e,d:\index", "[CLASS:ExploreWClass]", $hGUI, 0, 0, 600, 500)
GUISetState()

While 1
    $msg = GUIGetMsg()
    If $msg = -3 Then
        GUISetState(@SW_HIDE, $hGUI)
        WinClose($Exp1)
        WinClose($Exp2)
        ExitLoop
    EndIf
WEnd

Func _RunEmbExp($sRun, $sClass, $hGUI, $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI, $nStyle = -2, $nExStyle = -2)
    Local $iPID = Run($sRun, '', @SW_HIDE)
    WinWait($sClass)
    Return _WinEmbedToGUI(WinGetHandle($sClass), $hGUI, $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI, $nStyle, $nExStyle)
EndFunc

Func _WinEmbedToGUI($hWnd, $hGUI, $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI, $nStyle = -2, $nExStyle = -2)
    Local $nExStyleEx = DllCall("user32.dll", "int", "GetWindowLong", "hwnd", $hWnd, "int", -20)
    If IsArray($nExStyleEx) = 0 Then Return SetError(1, 0, 0)
    DllCall("user32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", -20, "int", BitOr($nExStyleEx[0], 0x00000040));WS_EX_MDICHILD
    DllCall("user32.dll", "int", "SetParent", "hwnd", $hWnd, "hwnd", $hGUI)
    WinSetState($hWnd, '', @SW_SHOW)
    WinMove($hWnd, "", $nLeftGUI, $nTopGUI, $nRightGUI, $nBottomGUI)
    If $nStyle = -2 And $nExStyle = -2 Then Return $hWnd
    Local $GWL_STYLE = -16, $GWL_EXSTYLE = -20
    Local $SWP_NOMOVE = 0x2, $SWP_NOSIZE = 0x1
    Local $SWP_SHOWWINDOW = 0x40, $SWP_NOZORDER = 0x4
    Local $iFlags = BitOR($SWP_SHOWWINDOW, $SWP_NOSIZE, $SWP_NOMOVE, $SWP_NOZORDER)
    If $nStyle = -2 Then $nStyle = $WS_MINIMIZEBOX + $WS_CAPTION + $WS_POPUP + $WS_SYSMENU
    If $nExStyle = -2 Then $nExStyle = $nExStyleEx[0]
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_STYLE, "int", $nStyle)
    DllCall("User32.dll", "int", "SetWindowLong", "hwnd", $hWnd, "int", $GWL_EXSTYLE, "int", $nExStyle)
    DllCall("User32.dll", "int", "SetWindowPos", "hwnd", $hWnd, "hwnd", 0, "int", 0, "int", 0, _
            "int", 0, "int", 0, "int", $iFlags)
    Return $hWnd
EndFunc

Edit:

Didn't like how it showed each explorer being closed before closing so I hid the GUI on exit first.

Edited by SmOke_N

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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