Popular Post LarsJ Posted November 28, 2013 Popular Post Share Posted November 28, 2013 (edited) Note that this is a real Windows Explorer. But only the right pane. All functionality of Windows Explorer is working. E.g. keyboard shortcuts, the context (right click) menu, cut, copy, paste, drag & drop and automatic update of the window.ImplementationsThere are three implementations: An implementation for Vista, 7 and 8, an implementation for Windows XP, and a SysListView32 based implementation for Vista, 7 and 8. The latter is named SysLv32.au3 in the examples. This is more or less the Windows XP implementation adapted for Vista, 7 and 8.FunctionalityThe implementations are based on Shell interfaces. This means that most functionality of Windows Explorer is working automatically without any additional code.Other features:Position Explorer window in GUISpecify root and start foldersSpecify an initial icon view modeSpecify an icon view mode for the DesktopSpecify a file filter to filter files by extensionUse folder flags $FWF_NOBACKBROWSING, $FWF_SINGLESEL and $FWF_NOSUBFOLDERSBrowse to child/parent folder with Enter/Backspace keysDelete, disable and insert items in the context menuExecute context menu commands in codeDocumentationUse ExplorerWindowCreate() to create the right pane window. This function is located in Explorer\<Implementation>\WindowsExplorer.au3. You find documentation for the function in top of the file. Documentation for the Vista, 7, 8 implementation is included in the Examples section below.Ini fileTo handle Rename, New and View in the context menu, it's necessary to be able to identify these items. This seems only to be possible to do, by identifying the names. Because the names are localized, an ini file is used to store the names.Especially the View command depends on the ini file. If the View command isn't recognized, the icon view modes are not set properly. Rename and New commands are depending on the ini file, when the commands are selected with the keyboard.The path for the ini file is Explorer\Inifiles\ContextMenu.ini. An English version is included in the zip. It's named ContextMenuUK.ini. If your Windows OS is using the English (UK) language, you just have to rename this file to ContextMenu.ini. If you are using another language, you must update the file with menu names in your own language. You can use example 5. Context menu to print the menu names.This is the contents of the ini file:[Context Menu Localized Names] sContextMenuNew=Ne&w sContextMenuRename=Rena&me iContextMenuRenameKey=0x4D ; $VK_M = 0x4D ; See WinAPIvkeysConstants.au3 sContextMenuView=&ViewYou also need the hex value of the accelerator key for the Rename command. For the English language this character is "m", and the hex value is 0x4D. You can find the hex value in WinAPIvkeysConstants.au3 (AutoIt 3.3.10 include file). You don't need shortcut characters for New and View commands (because they are submenus, not commands).To properly handle Rename, New and View items in the context menu, you must use Explorer\Inifiles\ContextMenu.ini. You only have to create the file onze. It's used in all three implementations and all examples.More information in the sections below. First release 2013-11-28In first release Explorer right pane windows are created with enough functionality to get it to work. There are two implementations: One for Vista, 7 and 8, and one for Windows XP.Windows Vista, 7 and 8Windows Explorer right pane windowOn Windows Vista, 7 and 8 the Explorer right pane window is created with the Initialize method of IExplorerBrowser. A pointer to an IExplorerBrowser object can be created with CoCreateInstance and the object can be created with ObjCreateInterface. Call BrowseToIDList to open a specific folder.This is the code to create Windows Explorer right pane. It opens a window containing the @ScriptDir folder.; IExplorerBrowser Local $pIExplorerBrowser CoCreateInstance( $tCLSID_IExplorerBrowser, $NULL, $CLSCTX_INPROC_SERVER, $tRIID_IExplorerBrowser, $pIExplorerBrowser ) $oIExplorerBrowser = ObjCreateInterface( $pIExplorerBrowser, $sIID_IExplorerBrowser, $dtag_IExplorerBrowser ) ; PIDL to @ScriptDir $pPidlHome = ILCreateFromPath( @ScriptDir ) ; Right pane window position and size Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, "Left", 0 ) DllStructSetData( $tRECT, "Top", $aTBsize[1] + 6 ) DllStructSetData( $tRECT, "Right", $iGuiWidth ) DllStructSetData( $tRECT, "Bottom", $iGuiHeight ) ; Create Windows Explorer right pane window $oIExplorerBrowser.Initialize( $hGui, DllStructGetPtr( $tRECT ), DllStructGetPtr( $tFOLDERSETTINGS ) ) $oIExplorerBrowser.BrowseToIDList( $pPidlHome, $SBSP_ABSOLUTE )Inline browsingInline browsing (when you double click a folder the folder opens in the current window) is enabled by default. IExplorerBrowserEvents must be implemented to get folder information (PIDLs) for Back and Parent buttons in the toolbar. IExplorerBrowserEvents responds to events of the window and must be created as a custom object with custom methods.Custom methodsThis can be done with _AutoItObject_ObjectFromDtag from AutoItObject (get v1.2.8.3 in post 302). _AutoItObject_ObjectFromDtag calls a few functions. If you take a look at DragDropEvent UDF - Handle OLE DragDrop Event by Ward, he has put these functions together into one function named __CreateCOMInterface which is independent of AutoItObject. Here is used a copy of this function with a few modifications and it's renamed to ObjCreateInterfaceEx. You find it in ResourcesIncludeObjCreateInterfaceEx.au3.The custom object is created with this line of code:$pIExplorerBrowserEvents = ObjCreateInterfaceEx( "oIExplorerBrowserEvents_", $dtag_IExplorerBrowserEvents, True )And this is the code for the custom methods. Only oIExplorerBrowserEvents_OnNavigationComplete contains more than a few lines.expandcollapse popup; === Custom interface methods === ; --- IExplorerBrowserEvents interface --- ; IExplorerBrowserEvents responds to browser events of the right pane window Func oIExplorerBrowserEvents_QueryInterface( $pSelf, $pRIID, $pObj ) ;ConsoleWrite( "oIExplorerBrowserEvents_QueryInterface" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIExplorerBrowserEvents_AddRef( $pSelf ) ;ConsoleWrite( "oIExplorerBrowserEvents_AddRef" & @CRLF ) $iIExplorerBrowserEvents_Ref += 1 Return $iIExplorerBrowserEvents_Ref EndFunc Func oIExplorerBrowserEvents_Release( $pSelf ) ;ConsoleWrite( "oIExplorerBrowserEvents_Release" & @CRLF ) $iIExplorerBrowserEvents_Ref -= 1 Return $iIExplorerBrowserEvents_Ref EndFunc Func oIExplorerBrowserEvents_OnNavigationPending( $pSelf, $pidlFolder ) ;ConsoleWrite( "oIExplorerBrowserEvents_OnNavigationPending" & @CRLF ) Return $S_OK EndFunc Func oIExplorerBrowserEvents_OnViewCreated( $pSelf, $psv ) ;ConsoleWrite( "oIExplorerBrowserEvents_OnViewCreated" & @CRLF ) Return $E_NOTIMPL EndFunc ; Get information for Back and Parent buttons in the toolbar Func oIExplorerBrowserEvents_OnNavigationComplete( $pSelf, $pidlFolder ) ;ConsoleWrite( "oIExplorerBrowserEvents_OnNavigationComplete" & @CRLF ) If Not $bToolBar Then ; Run this code only when a folder is double clicked. ; Not when the toolbar is used to open a new folder. ; Info for toolbar Back button AddLastFolderToBackButtonList() _WinAPI_CoTaskMemFree( $pPidlLast ) $pPidlLast = ILClone( $pidlFolder ) ; Info for toolbar Parent button _WinAPI_CoTaskMemFree( $pPidlParent ) $pPidlParent = ILClone( $pidlFolder ) ILRemoveLastID( $pPidlParent ) If Not $bParentButton Then _GUICtrlToolbar_SetButtonState( $hToolbar, $idParentButton, $TBSTATE_ENABLED ) $bParentButton = True EndIf Else $bToolBar = False EndIf Return $S_OK EndFunc Func oIExplorerBrowserEvents_OnNavigationFailed( $pSelf, $pidlFolder ) ;ConsoleWrite( "oIExplorerBrowserEvents_OnNavigationFailed" & @CRLF ) Return $S_OK EndFuncUsing the keyboardIInputObject must be implemented to use the keyboard (e.g. F2 to rename a file). IInputObject is exposed by $oIExplorerBrowser. You get a pointer to the object with QueryInterface and create the object with ObjCreateInterface. A hook procedure is used to catch window messages. Now you can forward keyboard shortcuts to Windows Explorer by calling TranslateAcceleratorIO of $oIInputObject with a pointer to the message as parameter.Control Panel issueThere is an issue with the Control Panel. If you double click the folder (Desktop is parent folder) the window doesn't open and the Desktop window seems to become unresponsive with respect to browsing. I'm not aware of the reason for this error. Click a toolbar button to open a new folder and get a responsive window. If you need the Control Panel take a look at this example. Windows XPWindows Explorer right pane windowOn Windows XP the Explorer right pane window is created with the CreateViewWindow method of the IShellView interface. The method takes a pointer to an IShellBrowser interface as parameter. The purpose of IShellBrowser is to respond to events of the window. IShellView is created with CreateViewObject of IShellFolder. IShellFolder can be created with various Shell functions.This is the code to create Windows Explorer right pane. It opens a window containing the @ScriptDir folder.; Custom object $pIShellBrowser = ObjCreateInterfaceEx( "oIShellBrowser_", $dtag_IShellBrowser, True ) ; IShellFolder for @ScriptDir Local $pParentFolder, $pidlRel, $pFolder $pPidlHome = ILCreateFromPath( @ScriptDir ) SHBindToParent( $pPidlHome, DllStructGetPtr( $tRIID_IShellFolder ), $pParentFolder, $pidlRel ) $oIShellFolder = ObjCreateInterface( $pParentFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Parent folder $oIShellFolder.BindToObject( $pidlRel, $NULL, $tRIID_IShellFolder, $pFolder ) $oIShellFolder = ObjCreateInterface( $pFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; @ScriptDir ; IShellView interface Local $pShellView $oIShellFolder.CreateViewObject( $hGui, $tRIID_IShellView, $pShellView ) $oIShellView = ObjCreateInterface( $pShellView, $sIID_IShellView, $dtag_IShellView ) ; Right pane window position and size Local $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, "Left", 0 ) DllStructSetData( $tRECT, "Top", $iToolbarHeight ) DllStructSetData( $tRECT, "Right", $iGuiWidth ) DllStructSetData( $tRECT, "Bottom", $iGuiHeight ) ; Create Windows Explorer right pane window $oIShellView.CreateViewWindow( $NULL, DllStructGetPtr( $tFOLDERSETTINGS ), $pIShellBrowser, DllStructGetPtr( $tRECT ), $hExplorer ) $hLVwin = ControlGetHandle( $hGui, "", "[CLASS:SHELLDLL_DefView; INSTANCE:1]" ) $hLV = ControlGetHandle( $hGui, "", "[CLASS:SysListView32; INSTANCE:1]" ) $oIShellView.UIActivate( $SVUIA_ACTIVATE_NOFOCUS )Custom methodsIShellBrowser must be implemented as a custom object with custom methods. Custom methods are used for two additional interfaces: ICommDlgBrowser and IServiceProvider. If ICommDlgBrowser isn't implemented CreateViewWindow creates a default Explorer window with a (blue) Task panel on the left side. To get a simple listview without the Task panel ICommDlgBrowser must be implemented. IServiceProvider is used to enable inline browsing. If you double click a folder the default action of IShellBrowser is to open a new Windows Explorer. To open the folder in the current window you must implement IServiceProvider.This is the code for the custom methods. Only oIShellBrowser_BrowseObject contains more than a few lines.expandcollapse popup; === Custom interface methods === ; --- IShellBrowser interface --- ; IShellBrowser responds to events of the right pane window Func oIShellBrowser_QueryInterface( $pSelf, $pRIID, $pObj ) ;ConsoleWrite( "oIShellBrowser_QueryInterface" & @CRLF ) ;ConsoleWrite( "$pRIID = " & _WinAPI_StringFromGUID( $pRIID ) & @CRLF ) If $pICommDlgBrowser And _WinAPI_StringFromGUID( $pRIID ) = $sIID_ICommDlgBrowser Then ; Get a pointer to the ICommDlgBrowser interface DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pICommDlgBrowser ) Return $S_OK ElseIf $pIServiceProvider And _WinAPI_StringFromGUID( $pRIID ) = $sIID_IServiceProvider Then ; Get a pointer to the IServiceProvider interface DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pIServiceProvider ) Return $S_OK EndIf Return $E_NOINTERFACE EndFunc Func oIShellBrowser_AddRef( $pSelf ) ;ConsoleWrite( "oIShellBrowser_AddRef" & @CRLF ) $iIShellBrowser_Ref += 1 Return $iIShellBrowser_Ref EndFunc Func oIShellBrowser_Release( $pSelf ) ;ConsoleWrite( "oIShellBrowser_Release" & @CRLF ) $iIShellBrowser_Ref -= 1 Return $iIShellBrowser_Ref EndFunc Func oIShellBrowser_GetWindow( $pSelf, $hExplorer ) ;ConsoleWrite( "oIShellBrowser_GetWindow" & @CRLF ) DllStructSetData( DllStructCreate( "hwnd", $hExplorer ), 1, $hGui ) Return $S_OK EndFunc Func oIShellBrowser_ContextSensitiveHelp( $pSelf, $fEnterMode ) ;ConsoleWrite( "oIShellBrowser_ContextSensitiveHelp" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_InsertMenusSB( $pSelf, $hmenuShared, $lpMenuWidths ) ;ConsoleWrite( "oIShellBrowser_InsertMenusSB" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_SetMenuSB( $pSelf, $hmenuShared, $holemenuRes, $hwndActiveObject ) ;ConsoleWrite( "oIShellBrowser_SetMenuSB" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_RemoveMenusSB( $pSelf, $hmenuShared ) ;ConsoleWrite( "oIShellBrowser_RemoveMenusSB" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_SetStatusTextSB( $pSelf, $lpszStatusText ) ;ConsoleWrite( "oIShellBrowser_SetStatusTextSB" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_EnableModelessSB( $pSelf, $fEnable ) ;ConsoleWrite( "oIShellBrowser_EnableModelessSB" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_TranslateAcceleratorSB( $pSelf, $lpmsg, $wID ) ;ConsoleWrite( "oIShellBrowser_TranslateAcceleratorSB" & @CRLF ) Return $S_OK EndFunc ; This method is used to browse to a new folder object Func oIShellBrowser_BrowseObject( $pSelf, $pidl, $wFlags ) ;ConsoleWrite( "oIShellBrowser_BrowseObject" & @CRLF ) ; Inspect $wFlags and use $pidl to get an ; IShellFolder interface for the new folder. If BitAND( $wFlags, $SBSP_RELATIVE ) Then ; Seems not to be any relative (to parent folder) PIDLs. ; If so cancel inline browsing and open folder in new window. Return $S_FALSE Else ; $SBSP_ABSOLUTE ; All PIDLs seems to be absolute (fully qualified) PIDLs. ; This means that the PIDLs are relative to the Desktop. ; Info for toolbar Back button AddLastFolderToBackButtonList() _WinAPI_CoTaskMemFree( $pPidlLast ) $pPidlLast = ILClone( $pidl ) Local $pFolder If ILIsEqual( $pidl, $pPidlDesktop ) Then ; IShellFolder interface $oIShellFolder = $oIDesktopFolder Else ; IShellFolder interface $oIDesktopFolder.BindToObject( $pidl, $NULL, $tRIID_IShellFolder, $pFolder ) $oIShellFolder = ObjCreateInterface( $pFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Info for toolbar Parent button _WinAPI_CoTaskMemFree( $pPidlParent ) $pPidlParent = ILClone( $pidl ) ILRemoveLastID( $pPidlParent ) If Not $bParentButton Then _GUICtrlToolbar_SetButtonState( $hToolbar, $idParentButton, $TBSTATE_ENABLED ) $bParentButton = True EndIf EndIf ; Create Windows Explorer right pane window CreateWinExplorerRightPane() If $hLVwin Then Return $S_OK Else Return $S_FALSE ; This cancels inline browsing and ; opens the folder in a new window. EndIf EndIf EndFunc Func oIShellBrowser_GetViewStateStream( $pSelf, $grfMode, $ppStrm ) ;ConsoleWrite( "oIShellBrowser_GetViewStateStream" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_GetControlWindow( $pSelf, $id, $lphwnd ) ;ConsoleWrite( "oIShellBrowser_GetControlWindow" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_SendControlMsg( $pSelf, $id, $uMsg, $wParam, $lParam, $pret ) ;ConsoleWrite( "oIShellBrowser_SendControlMsg" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_QueryActiveShellView( $pSelf, $ppshv ) ;ConsoleWrite( "oIShellBrowser_QueryActiveShellView" & @CRLF ) Return $S_OK EndFunc Func oIShellBrowser_OnViewWindowActive( $pSelf, $ppshv ) ;ConsoleWrite( "oIShellBrowser_OnViewWindowActive" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIShellBrowser_SetToolbarItems( $pSelf, $lpButtons, $nButtons, $uFlags ) ;ConsoleWrite( "oIShellBrowser_SetToolbarItems" & @CRLF ) Return $E_NOTIMPL EndFunc ; --- ICommDlgBrowser interface --- ; If ICommDlgBrowser isn't implemented a default Explorer window with a Task panel on the left side ; is created. To get a simple listview without the Task panel ICommDlgBrowser must be implemented. Func oICommDlgBrowser_QueryInterface( $pSelf, $pRIID, $pObj ) ;ConsoleWrite( "oICommDlgBrowser_QueryInterface" & @CRLF ) Return $E_NOTIMPL EndFunc Func oICommDlgBrowser_AddRef( $pSelf ) ;ConsoleWrite( "oICommDlgBrowser_AddRef" & @CRLF ) $iICommDlgBrowser_Ref += 1 Return $iICommDlgBrowser_Ref EndFunc Func oICommDlgBrowser_Release( $pSelf ) ;ConsoleWrite( "oICommDlgBrowser_Release" & @CRLF ) $iICommDlgBrowser_Ref -= 1 Return $iICommDlgBrowser_Ref EndFunc Func oICommDlgBrowser_OnDefaultCommand( $pSelf, $ppshv ) ;ConsoleWrite( "oICommDlgBrowser_OnDefaultCommand" & @CRLF ) Return $E_NOTIMPL EndFunc Func oICommDlgBrowser_OnStateChange( $pSelf, $ppshv, $uChange ) ;ConsoleWrite( "oICommDlgBrowser_OnStateChange" & @CRLF ) Return $E_NOTIMPL EndFunc Func oICommDlgBrowser_IncludeObject( $pSelf, $ppshv, $pidl ) ;ConsoleWrite( "oICommDlgBrowser_IncludeObject" & @CRLF ) Return $S_OK EndFunc ; --- IServiceProvider interface --- ; IServiceProvider is used to enable inline browsing. If you double click a folder the default action of IShellBrowser is to ; open a new Windows Explorer in a new window. To open the folder in the current window you must implement IServiceProvider. Func oIServiceProvider_QueryInterface( $pSelf, $pRIID, $pObj ) ;ConsoleWrite( "oIServiceProvider_QueryInterface" & @CRLF ) Return $E_NOTIMPL EndFunc Func oIServiceProvider_AddRef( $pSelf ) ;ConsoleWrite( "oIServiceProvider_AddRef" & @CRLF ) $iIServiceProvider_Ref += 1 Return $iIServiceProvider_Ref EndFunc Func oIServiceProvider_Release( $pSelf ) ;ConsoleWrite( "oIServiceProvider_Release" & @CRLF ) $iIServiceProvider_Ref -= 1 Return $iIServiceProvider_Ref EndFunc Func oIServiceProvider_QueryService( $pSelf, $pGuidService, $pRIID, $pObj ) ;ConsoleWrite( "oIServiceProvider_QueryService" & @CRLF ) ;ConsoleWrite( "$pGuidService = " & _WinAPI_StringFromGUID( $pGuidService ) & @CRLF ) ;ConsoleWrite( "$pRIID = " & _WinAPI_StringFromGUID( $pRIID ) & @CRLF ) If _WinAPI_StringFromGUID( $pGuidService ) = $sIID_IShellBrowser Then ; This code is executed when you double click a folder. ; It's needed to implement inline browsing. DllStructSetData( DllStructCreate( "ptr", $pObj ), 1, $pIShellBrowser ) Return $S_OK EndIf Return $E_NOINTERFACE EndFuncUsing the keyboardThe procedure is the same as for Vista, 7 and 8 but TranslateAccelerator of $oIShellView is used instead of TranslateAcceleratorIO of $oInputObject.Control PanelNo issues with the Control Panel on Windows XP. First update 2014-03-14This update consists primarily of bug fixes in first release. Because both APIConstants.au3 and WinAPIEx.au3 are included, the scripts can't run on AutoIt 3.3.10 without modifications.A new implementation for Vista, 7 and 8 is added. This implementation is based on a SysListView32 control. This is more or less the Windows XP implementation adapted for Vista, 7 and 8.Updates for all three implementations:Code adapted for AutoIt 3.3.10 (only a matter of UDFs)Custom interface objects are created with ObjectFromTag in this post by trancexxAdded code to maximize and restore the GUI window (forgot that in first release)Included a new file, WindowsExplorer.au3, which makes the start script smallerThe GUI can be opened in an optional folder with an optional icon view modeUpdate for the Vista, 7 and 8 implementation:Resize issue when run as a 32 bit script is resolvedUpdates for the Windows XP implementation:When inline browsing was done by pressing the Enter key on a folder, the script crashed. Resolved.Some files e.g. zip files didn't open when activated with a double click or the Enter key. Resolved by using the InvokeCommand for the default item in the context menu to activate the file.Added a file filter to include/exclude files by extension. Also added for the new SysLv32 version.New implementationThe new implementation for Vista, 7 and 8 is based on a SysListView32 control, and is more or less the Windows XP implementation adapted for Vista and later. Note that it will not run properly on Windows XP.Because the listview is created with IShellView (for XP) and not IExplorerBrowser (for Vista), inline browsing can't be handled with the usual methods. Instead, inline browsing is handled by catching double click and Enter keypress events for folders, and then code is added to browse to the new folder (on XP the browser events are handled in the BrowseObject method, but also on XP you must add code to browse to the new folder).A file filter can be applied to include/exclude files by extension.There is an issue with the Control Panel. Second update 2014-04-23The implementations are based on Shell interfaces, and most functionality of Windows Explorer is working automatically. But you still have to integrate that functionality into your script. Especially you have to take care of keystrokes in combination with various controls and windows. E.g. the rename edit box, the context menu and dialog boxes.This update introduces an ini file: Explorer\Inifiles\ContextMenu.iniRenameWhen you are renaming an item, the keystrokes in the rename edit box must not be forwarded to the Explorer window. If e.g. the Backspace key is forwarded to the Explorer window, this will make the Explorer browse to the parent folder.You can switch to rename mode in four ways: Pressing F2 key, left mouse click on a selected item, selecting Rename or New in the context menu. In previous versions only F2 key was working.Context menuIf you right click an item, the context menu opens automatically. In your code, you must be aware, that the context menu is open and has focus. If the Enter key is used to execute a menu item, you must make sure, that the keystroke is not forwarded to the Explorer window.The context menu can be opened with a right mouse click, Shift+F10 and the Context menu key.Dialog boxesIf a dialog box is open, keystrokes must not be forwarded to the Explorer window.This integration is implemented in the MessageHandler function. The $WM_KEYDOWN case is divided into four sections: Rename mode, Context menu mode, Dialog mode and Navigation mode:expandcollapse popupFunc MessageHandler( $nCode, $wParam, $lParam ) If $nCode < 0 Then Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) Local $tMSG = DllStructCreate( $tagMSG, $lParam ) Local $iMsg = DllStructGetData( $tMSG, "message" ) Local Static $fShift = False Switch $iMsg Case $WM_MOUSEMOVE, $WM_TIMER ; There are a lot of these events and they are not used. Get rid of these ; events so that they are not tested in all the Case statements below. Case $WM_KEYFIRST To $WM_KEYLAST Switch $iMsg Case $WM_KEYDOWN Select Case $bRenameEditOpen ; --- Rename mode --- ; Rename mode can be enabled with F2 key, mouse left ; click, selecting Rename or New in the context menu. ; This prevents the keystrokes in the rename ; edit box to be passed to the right pane window, ; and it prevents each key to be repeated twice. Switch DllStructGetData( $tMSG, "wParam" ) Case $VK_RETURN, $VK_ESCAPE $oIInputObject.TranslateAcceleratorIO( $lParam ) $bRenameEditOpen = False EndSwitch Case $bContextMenuOpen ; --- Context menu mode --- ; The context menu can be opened with a right mouse click, ; pressing Shift+F10 or pressing the Context menu key. ; This prevents the keystrokes in the context ; menu to be passed to the right pane window. Switch DllStructGetData( $tMSG, "wParam" ) Case $VK_RETURN, $VK_DELETE EndSwitch Case $bDialogBoxOpen ; --- Dialog mode --- ; A dialog is opened e.g. when the Delete key is pressed ; This prevents the keystrokes in a dialog ; to be passed to the right pane window. Switch DllStructGetData( $tMSG, "wParam" ) Case $VK_RETURN EndSwitch Case Else ; --- Navigation mode --- Switch DllStructGetData( $tMSG, "wParam" ) Case $VK_BACK ; Browse to parent folder with Backspace key If ILIsEqual( $pPidlParent, $pPidlRoot ) Then _ Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) Return BrowseToParentFolder( $lParam ) Case $VK_SHIFT $fShift = True ; Used when the context menu is opened with Shift+F10 Case $VK_PRIOR To $VK_DOWN Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) ; PRIOR, NEXT, END, HOME, LEFT, UP, RIGHT, DOWN ; Prevents each key to be repeated twice Case $VK_F2 ; Rename $oIInputObject.TranslateAcceleratorIO( $lParam ) $bRenameEditOpen = True Return True Case Else If $oIInputObject.TranslateAcceleratorIO( $lParam ) = $S_OK Then Return True Else Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) EndIf EndSwitch EndSelect ;Case $WM_KEYDOWN ends Case $WM_KEYUP Switch DllStructGetData( $tMSG, "wParam" ) Case $VK_SHIFT $fShift = False Case $VK_DELETE $bDialogBoxOpen = True $bClearMessageHandlerFlags = BitOR( $bClearMessageHandlerFlags, 1 ) ; For Delete key you must respond to $WM_KEYUP EndSwitch Case $WM_SYSKEYDOWN Switch DllStructGetData( $tMSG, "wParam" ) Case $VK_F10 If $fShift Then StartContextMenuMessages() ; Context menu opened with Shift+F10 ; Handle messages from context menu ; (F10 is not catched by $WM_KEYDOWN) EndSwitch Case Else Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) EndSwitch Case $WM_LBUTTONDOWN If $bRenameEditOpen Then $bRenameEditOpen = False ; Rename is terminated by clicking another item ElseIf Not $bRenOnLeftMouseClick Then ; A rename can be initiated by clicking the ; selected item with the left mouse button. ; If a $WM_SYSTIMER event is generated before timeout, ; then rename mode will be enabled. See $WM_SYSTIMER below. $bRenOnLeftMouseClick = True $hMessageHandlerTimer = TimerInit() $bClearMessageHandlerFlags = BitOR( $bClearMessageHandlerFlags, 2 ) EndIf Case $WM_LBUTTONDBLCLK If $bRenOnLeftMouseClick Then ClearMessageHandlerTimer() If $bContextMenuOpen Then _ Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) Case $WM_CONTEXTMENU StartContextMenuMessages() ; Context menu opened with the Context menu key ; Handle messages from Explorer context menu Case $WM_RBUTTONUP ; Context menu opened with mouse right click Local $tPoint = DllStructCreate( "int X;int Y" ) DllStructSetData( $tPoint, "X", DllStructGetData( $tMSG, "X" ) ) DllStructSetData( $tPoint, "Y", DllStructGetData( $tMSG, "Y" ) ) ; Handle messages from Explorer context menu StartContextMenuMessages( $tPoint ) Case $WM_SYSTIMER ; Rename with left click on selected item. ; Rename for some of the New submenu items in the context menu. ; WM_SYSTIMER = 0x0118 is generated by the blinking cursor in the edit box. ; If $bRenOnLeftMouseClick is true or $bContextMenuNew is true and a $WM_SYSTIMER ; event is generated before timeout (2 seconds), then rename mode will be enabled. If ( $bRenOnLeftMouseClick Or $bContextMenuNew ) And Not $bRenameEditOpen Then $bRenameEditOpen = True $bRenOnLeftMouseClick = False $bContextMenuNew = False $hMessageHandlerTimer = 0 EndIf Case Else Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) EndSwitch EndFuncThe code box shows the Vista, 7, 8 implementation.Rename, New and View items in the context menuTo handle Rename, New and View in the context menu, it's necessary to be able to identify these items. This seems only to be possible to do, by identifying the names. Because the names are localized, an ini file is used to store the names.The path for the file is Explorer\Inifiles\ContextMenu.ini. An English version is included in the zip. It's named ContextMenuUK.ini. If your Windows OS is using the English (UK) language, you just have to rename this file to ContextMenu.ini. If you are using another language, you must update the file with menu names in your own language.This is the contents of the ini file:[Context Menu Localized Names] sContextMenuNew=Ne&w sContextMenuRename=Rena&me iContextMenuRenameKey=0x4D ; $VK_M = 0x4D ; See WinAPIvkeysConstants.au3 sContextMenuView=&ViewYou also need the hex value of the accelerator key for the Rename command. For the English language this character is "m", and the hex value is 0x4D. You can find the hex value in WinAPIvkeysConstants.au3 (AutoIt 3.3.10 include file). You don't need shortcut characters for New and View commands (because they are submenus, not commands).To properly handle Rename, New and View items in the context menu, you must use Explorer\Inifiles\ContextMenu.ini. You only have to create the file onze. It's used in all three implementations and all examples.The function CMMessageHandler in ExplorerIncludeCMMessageHandler.au3 handles messages from the context menu:expandcollapse popupFunc CMMessageHandler( $nCode, $wParam, $lParam ) If $nCode <> $MSGF_MENU Then Return 0 ;Return _WinAPI_CallNextHookEx( 0, $nCode, $wParam, $lParam ) Local Static $iIndex, $bRename, $bNew, $hNewMenu, $bView, $hViewMenu Local $tMSG = DllStructCreate( $tagMSG, $lParam ), $sText Switch DllStructGetData( $tMSG, "message" ) Case $WM_MOUSEMOVE, $WM_TIMER ; There are a lot of these events and they are not used. Get rid of these ; events so that they are not tested in all the Case statements below. Case $WM_MENUSELECT ; This code runs every time an item is hilited Local $iwParam = DllStructGetData( $tMSG, "wParam" ), $flags = BitShift( $iwParam, 16 ) If BitAND( $flags, $MF_HILITE ) And Not BitAND( $flags, $MF_GRAYED ) And Not BitAND( $flags, $MF_DISABLED ) Then ; Identifies when Rename, New or View is hilited Local $hMenu = DllStructGetData( $tMSG, "lParam" ) Switch $hMenu Case $hNewMenu If Not $bNew Then _ $bNew = True Case $hViewMenu $iIndex = BitAND( $iwParam, 0xFFFF ) ;$sText = _GUICtrlMenu_GetItemText( $hMenu, $iIndex, False ) ;ConsoleWrite( "Index, text = " & $iIndex & ", " & $sText & @CRLF ) If Not $bView Then $bView = True Case Else $iIndex = BitAND( $iwParam, 0xFFFF ) If $iIndex < 100 Then $sText = _GUICtrlMenu_GetItemText( $hMenu, $iIndex ) ElseIf $iIndex > 99 Then $sText = _GUICtrlMenu_GetItemText( $hMenu, $iIndex, False ) EndIf ;ConsoleWrite( "Index, text = " & $iIndex & ", " & $sText & @CRLF ) ; <<<<<<<<<<<<<<< Switch $sText ; If you remove the comment character in above line, me- Case $sContextMenuRename ; nu item indices and names are printed in Scite console, $bRename = True ; when an item is hilited. $bView = False $bNew = False Case $sContextMenuNew $hNewMenu = _GUICtrlMenu_GetItemSubMenu( $hMenu, $iIndex ) $bRename = False $bView = False $bNew = False Case $sContextMenuView If Not $iViewMenuOffset Then $hViewMenu = _GUICtrlMenu_GetItemSubMenu( $hMenu, $iIndex ) $iViewMenuOffset = DisableViewMenuItems( $hViewMenu ) EndIf $bRename = False $bView = False $bNew = False Case Else $bRename = False $bView = False $bNew = False EndSwitch EndSwitch Else $bRename = False $bView = False $bNew = False EndIf Return 0 Case $WM_KEYDOWN ; Identifies an item SELECTED with the keyboard Switch DllStructGetData( $tMSG, "wParam" ) Case $VK_RETURN Select Case $bRename $bRenameEditOpen = True Case $bNew $bContextMenuNew = True $hMessageHandlerTimer = TimerInit() $bClearMessageHandlerFlags = BitOR( $bClearMessageHandlerFlags, 2 ) ; A rename can be initiated by selecting New in the context menu. ; If a $WM_SYSTIMER event is generated before timeout, then rename ; mode will be enabled. See $WM_SYSTIMER event in MessageHandler(). Case $bView Local $iView = $iIndex - $iViewMenuOffset $iViewMode = $aViewIndexToMode[$iView] DllStructSetData( $tFOLDERSETTINGS, "ViewMode", $iViewMode ) SetViewFolderSettings( $iView ) EndSelect Case $iContextMenuRenameKey $bRenameEditOpen = True EndSwitch Return 0 Case $WM_LBUTTONUP, $WM_RBUTTONUP ; Identifies an item SELECTED with the mouse Select Case $bRename $bRenameEditOpen = True Case $bNew $bContextMenuNew = True $hMessageHandlerTimer = TimerInit() $bClearMessageHandlerFlags = BitOR( $bClearMessageHandlerFlags, 2 ) ; A rename can be initiated by selecting New in the context menu. ; If a $WM_SYSTIMER event is generated before timeout, then rename ; mode will be enabled. See $WM_SYSTIMER event in MessageHandler(). Case $bView Local $iView = $iIndex - $iViewMenuOffset $iViewMode = $aViewIndexToMode[$iView] DllStructSetData( $tFOLDERSETTINGS, "ViewMode", $iViewMode ) SetViewFolderSettings( $iView ) EndSelect Return 0 EndSwitch Return 0 EndFuncIf you remove the comment character in line 35, menu item indices and names are printed in Scite console, when an item is hilited. You can copy the names for Rename, New and View commands and insert into the ini file.Other improvementsBrowse to parent folder with Backspace keyKeeping focus on right pane window when browsing with Enter/Backspace keysAn issue with double clicking "My Documents" on Windows XP Desktop is resolvedFile filter implemented for Vista,7,8 with IFolderFilterSite and IFolderFilter interfacesWorkaround for Control Panel issue on Vista,7,8 and SysLv32: Control Panel is opened in new windowSelecting a View mode in context menu, will also apply when you browse to a new folderFolder parameters in ExplorerWindowCreate can be specified in three ways:$sFolder = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ; My Computer$sFolder = $CSIDL_PERSONAL ; See APIShellExConstants.au3 for CSIDLs$sFolder = "C:Windows" ; A normal folder pathYou can specify a root folder for the right pane windowYou can specify an icon view mode for the DesktopToolbar exampleOptionally use small or large icons in the toolbarThe View items in the dropdown button are coordinated with the View items in the context menu Third update 2014-05-02The third update is mostly about the context menu. It's divided into two parts. The first part is about manipulating the context menu. The example shows how to delete, disable and add custom menu items. The second part shows how to execute context menu commands in code. The example implements Cut, Copy and Paste buttons.The spoiler section starts with an explanation of the message flow and message handlers.To handle the context menu, you must be aware of the message flow.Message handlersThere are three message handlers in the program. The first is the usual GUI message handler that handles events from AutoIt controls. It's located in <Example>\<Implementation>.au3.The second is the right pane message handler. It's monitoring messages from the Explorer right pane window and the listview control. It's coded in MessageHandler() in Explorer\<Implementation>\WindowsExplorer.au3.These two message handlers are running simultaneously most of the time.The third is the context menu message handler. It's implemented in CMMessageHandler() in Explorer\Include\CMMessageHandler.au3. It's only running when the context menu is open.When the context menu is open, the GUI message loop is blocked. The right pane message handler is still running, but the (context menu) messages are skipped in top of the function.When a dialog box is open e.g. the confirm delete dialog box, the GUI loop is also blocked, the right pane loop is still running, but the (dialog box) messages are skipped.When the context menu or dialog box is closed, the GUI loop starts running immediately.Because the GUI loop behaves in this way, it's a convenient place to handle flags, used to control the actions in the context menu and dialog boxes.In top of the GUI message loop, code like this is implemented:If $bMessageHandlerFlags Then If $idContextMenuCmd Then _ ; These two lines handles HandleContextMenuCmd( $idContextMenuCmd ) ; custom context menu commands. ClearMessageHandlerFlags() EndIfManipulating the context menuWhen the context menu is opened, an event is generated in the right pane message handler. This event is used to start the context menu message handler.CMMessageHandler() finds the handle for the window that contains the menu. Then it sends a $MN_GETHMENU message to the window to get a handle for the context menu.To delete or disable menu items, it's necessary to be able to identify the items. The names of the items are used for identification. Because the names are localized, an ini file is used to store the names. The path for this file is <Example>\Explorer\Inifiles\ContextMenu.ini.For example 5. Context menu an English version is included in the zip. It's named ContextMenuUK.ini. In the example the Rename command is deleted, and the Delete command is disabled. If your Windows OS is using the English (UK) language, you just have to rename this file to ContextMenu.ini. If you are using another language, you also have to update the file with menu item names in your own language.To actually delete and disable the commands you also have to enable this code in 5. Context menu\Explorer\Include\ContextMenu.au3:Func DeleteContextMenuItems( ByRef $hContext ) Return ; Comment out or remove this line to delete context menu items ; The 4-flag tells that context menu items are deleted $bContextMenuOpen = BitOR( $bContextMenuOpen, 4 ) ; Get handle for context menu If Not $hContext Then $hContext = GetContextMenuHandle() If $hContext = 0 Then Return EndIf ; Delete context menu items DoDeleteContextMenuItems( $aDeleteContextMenuItems, $hContext ) EndFunc Func DisableContextMenuItems( ByRef $hContext ) Return ; Comment out or remove this line to disable context menu items ; The 8-flag tells that context menu items are disabled $bContextMenuOpen = BitOR( $bContextMenuOpen, 8 ) ; Get handle for context menu If Not $hContext Then $hContext = GetContextMenuHandle() If $hContext = 0 Then Return EndIf ; Disable context menu items DoDisableContextMenuItems( $aDisableContextMenuItems, $hContext ) EndFuncNote that the functions are not enabled.To add custom context menu items you have to add the items directly in code:Func AddContextMenuItems( ByRef $hContext ) ;Return ; Comment out or remove this line to add context menu items ; The 16-flag tells that custom context menu items are added $bContextMenuOpen = BitOR( $bContextMenuOpen, 16 ) ; Get handle for context menu If Not $hContext Then $hContext = GetContextMenuHandle() If $hContext = 0 Then Return EndIf ; Code to add custom context menu items Local $hDisplayFilesAndFolders = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_AddMenuItem( $hDisplayFilesAndFolders, "All", $idCmdDisplayFilesAndFoldersAll ) _GUICtrlMenu_AddMenuItem( $hDisplayFilesAndFolders, "Files", $idCmdDisplayFilesAndFoldersFiles ) _GUICtrlMenu_AddMenuItem( $hDisplayFilesAndFolders, "Folders", $idCmdDisplayFilesAndFoldersFolders ) _GUICtrlMenu_AddMenuItem( $hDisplayFilesAndFolders, "Selected", $idCmdDisplayFilesAndFoldersSelected ) If Not CheckSelectedItems() Then _GUICtrlMenu_SetItemGrayed( $hDisplayFilesAndFolders, 3 ) _GUICtrlMenu_AddMenuItem( $hContext, "" ) _GUICtrlMenu_AddMenuItem( $hContext, "Display files and folders", 0, $hDisplayFilesAndFolders ) _GUICtrlMenu_AddMenuItem( $hContext, "Display context menu items", $idCmdDisplayContextMenuItems ) ; Get context menu items ; Since a custom command is added to display the context menu ; items, we'll fill an array with the items at this point. Local $iCount = _GUICtrlMenu_GetItemCount( $hContext ) ReDim $aContextMenu[$iCount][3] For $i = 0 To $iCount - 1 $aContextMenu[$i][0] = $i $aContextMenu[$i][1] = _GUICtrlMenu_GetItemID( $hContext, $i ) $aContextMenu[$i][2] = _GUICtrlMenu_GetItemText( $hContext, $i ) Next EndFuncNote that the function is enabled.Command ids 0x7000 (28672) - 0x78FF (30975) can be used for custom context menu items. 0x0001 ($idCmdFirst) - 0x6FFF ($idCmdLast) are reserved. Ids higher than 0x7900 ($idCmdSys) are used for existing context menu items. 0x7900 (30976) is the Select command.If you run example 5. Context menu, it looks like this:The last command shows the items in the context menu with _ArrayDisplay. You can use this example to get localized names for context menu items.This is the output for a folder:0 31095 &Open 1 31098 Op&en in new window 2 0 3 31092 S&hare with 4 31087 Restore previous &versions 5 31086 6 31053 &Include in library 7 31052 Scan selected files with A&vira 8 31485 9 31051 Se&nd to 10 31484 11 31001 Cu&t 12 31002 &Copy 13 31003 &Paste 14 4294967295 15 30993 Create &shortcut 16 30994 &Delete 17 30995 Rena&me 18 31486 19 30996 P&roperties 20 0 21 0 Display files and folders 22 28676 Display context menu itemsNote the command ids for Cut, Copy and Paste.Executing context menu commandsIf you know the id of a command, you can execute the command by filling a $tagCMINVOKECOMMANDINFO structure and call InvokeCommand method of the IContextMenu interface:; Create and fill a $tagCMINVOKECOMMANDINFO structure Local $tCMINVOKECOMMANDINFO = DllStructCreate( $tagCMINVOKECOMMANDINFO ) DllStructSetData( $tCMINVOKECOMMANDINFO, "cbSize", DllStructGetSize( $tCMINVOKECOMMANDINFO ) ) DllStructSetData( $tCMINVOKECOMMANDINFO, "fMask", 0 ) DllStructSetData( $tCMINVOKECOMMANDINFO, "hWnd", $hWnd ) DllStructSetData( $tCMINVOKECOMMANDINFO, "lpVerb", $idCmd - $idCmdSys - $idCmdFirst ) DllStructSetData( $tCMINVOKECOMMANDINFO, "nShow", $SW_SHOWNORMAL ) ; Invoke the command $oIContextMenu.InvokeCommand( $tCMINVOKECOMMANDINFO )Note that this only works for commands that are provided with a canonical verb. Note also the calculation of the menu identifier offset for the lpVerb field.For some commands e.g. Cut and Copy you have to create a list of selected files/folders, before you execute the command.If you run example 6. Cut-copy-paste, it looks like this:Right pane settingsIn this update a few flags are introduced to use settings for the right pane window:$FWF_NOBACKBROWSING - Do not allow back (upward) browsing with Backspace key$FWF_SINGLESEL - Do not allow more than a single item to be selected$FWF_NOSUBFOLDERS - Do not show subfoldersThe flags $FWF_NOBACKBROWSING and $FWF_NOSUBFOLDERS disables browsing (unless browsing is implemented with a button or a similar control).Error correctionsBug fixes for the Vista, 7 and 8 implementation:Focus issue when using Backspace key to browse to parent folder is resolvedIssue with catching the mouse double click event in the message handler is resolvedWhen browsing to the Desktop and possibly changing icon view mode, the Desktop is properly refreshedThe bug fixes are implemented in the examples. Final release 2014-05-10Left, top, width and height parameters are added to the ExplorerWindowCreate() function. This makes it easier to position the Explorer window in the GUI. When the GUI is resized, the Explorer window is resized so that margins are retained. The margins can be used for buttons or other controls. The new parameters are implemented in the examples.Redundant code is moved from example files to common files. Some minor bug fixes.This is the final release of the small examples. It should not be too difficult to reuse the examples and code.I'm currently working on a large example where an address bar, a toolbar, a left pane and a status bar is implemented besides the right pane. This is a much bigger example, and it'll be more difficult to reuse the code. I'll probably add this example to a new thread. Final release, Vista update 2014-06-21The Vista, 7, 8 example in first release dated 2013-11-28 was based on Vista code. The XP example was based on XP code. But most of the additional code in the next updates was XP code (see post 40). This meant that some functionality wasn't implemented completely under Vista and later. E.g. icon view modes.Icon view modesIn XP, Vista and Windows 7/8 there are respectively 5, 7 and 8 view modes. To implement the new modes added in Vista and Windows 7, you need Vista code.In this update, XP code in SysLv32 and Vista, 7, 8 versions to handle icon view modes, is replaced with Vista code. This means that all the icon view modes in Vista and later are available. All examples updated to use this code. The modes can be used as parameters in ExplorerWindowCreate().The code is based on IFolderView2 interface and SetViewModeAndIconSize method. IFolderView2 runs on Vista and later.Columns in details viewWith IColumnManager interface available on Vista and later, you can store column information in a structure variable, and restore the columns when you browse to a new folder.Since columns are stored in a variable and not saved anywhere, columns can only be restored in the current session. When you start the script next time, it'll start up with the columns, you have defined in Windows Explorer.Implemented for SysLv32 and Vista, 7, 8 versions. All examples updated to use this code.In previous versions the columns were not restored in a new folder. This is still the case for the XP version.Summary of updatesThere are also a few updates of the XP code, and there are some updates of the examples.General updates:Added code to prevent error on early exit. See post 41 by Sunaj.SysLv32 and Vista, 7, 8 updates:XP code replaced by Vista code to implement more functionality. The new Vista code is based on IFolderView2 and IColumnManager interfaces.XP updates:IFolderView.SetCurrentViewMode is used to set icon view mode. In previous versions the FOLDERSETTINGS structure was updated manually.Example updates:SysLv32 and Vista, 7, 8 examples: All examples are updated to use the new icon view modes.SysLv32 and Vista, 7, 8 examples: All examples are updated to restore columns, when you browse to a new folder.4. Toolbar example: Folder names in folder list for the Back button (see picture in top of post) are genereated with $oIShellFolder.GetDisplayNameOf. This means localized and meaningful names for system folders. In previous versions the English names "Desktop", "My Computer" and "System Folder" were used.4. Toolbar example: Seamless integration between the menu items of the View button (see picture), and the menu items of the View command in the context menu.6. Cut-copy-paste: Minor updates of functionality. ExamplesThe zip contains seven folders at the top level:1. Basic example2. Position and size3. Navigation buttons4. Toolbar example5. Context menu6. Cut-copy-pasteExplorerThe first six folders are examples. The Explorer folder contains common files and includes. Resources specific for a particular example are contained in the example folder.There are three scripts for each example: Vista, 7, 8.au3, SysLv32.au3 and Windows XP.au3.The right pane window is created with the function ExplorerWindowCreate(). This function is located in Explorer\<Implementation>\WindowsExplorer.au3. Documentation in top of file. This is documentation for the Vista, 7, 8 implementation:expandcollapse popup; Create Explorer window ; ; ExplorerWindowCreate( $iLeft, $iTop, $iWidth, $iHeight, _ ; x, y, w, h relative to GUI, resize => margins retained ; $hGui, $sRoot = "", $sFolder = "", _ ; Main GUI handle, root folder and start/home folder ; $iFolderFlags = 0, _ ; $FWF_NOBACKBROWSING, $FWF_SINGLESEL, $FWF_NOSUBFOLDERS ; $sFilter = "", $bFilterIncl = 1, _ ; File filter to include or exclude files by extension ; $iView = $FVM_DETAILS, $iDesktopView = $FVM_ICON ) ; Initial icon view mode and icon view for the Desktop ; ; $iLeft, $iTop, $iWidth, $iHeight - Specifies x, y, w, h relative to GUI ; $iLeft, $iTop, $iWidth, $iHeight = 0, 0, 0, 0 ; Use entire GUI for Explorer window ; $iLeft, $iTop, $iWidth, $iHeight = -1, -1, -1, -1 ; Use entire GUI for Explorer window ; To make space in left side or in top of GUI for controls just specify $iLeft and $iTop ; Then $iWidth and $iHeight will be calculated to make Explorer fill the rest of the GUI ; When main GUI is resized, the Explorer window is resized so that margins are retained ; ; $hGui - Specifies the main GUI window handle ; ; $sRoot - Specifies the root folder of the Explorer window, default is "" which means Desktop ; (It's not possible to browse to a higher folder level, than the root folder.) ; If $sRoot is specified (not default), it must be a full path. ; $sRoot = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ; My Computer ; $sRoot = $CSIDL_PERSONAL ; See APIShellExConstants.au3 for CSIDLs ; $sRoot = "C:\" ; ; $sFolder - Specifies the startup folder within the root folder, default is "" which sets $sFolder = $sRoot ; If $sFolder is specified (not default), it must be a full path. ; If $sRoot and $sFolder are both specified, it is checked that ; $sRoot is a parent of $sFolder. If not then $sFolder = $sRoot. ; $sFolder = "::{20D04FE0-3AEA-1069-A2D8-08002B30309D}" ; My Computer ; $sFolder = $CSIDL_PERSONAL ; See APIShellExConstants.au3 for CSIDLs ; $sFolder = "C:\Windows" ; ; $iFolderFlags - Specifies flags that are applied to the folder, default is $iFolderFlags = 0 ; $iFolderFlags = $FWF_NOBACKBROWSING ; Do not allow back (upward) browsing with Backspace key ; $iFolderFlags = $FWF_SINGLESEL ; Do not allow more than a single item to be selected ; $iFolderFlags = $FWF_NOSUBFOLDERS ; Do not show subfolders ; ; $sFilter - Specifies a file filter to include or exclude files ; $sFilter = "" ; No File filter (default) ; $sFilter = "log;txt" ; File filter ; ; $bFilterIncl - Specifies if the filter includes or excludes files ; $bFilterIncl = 1 ; Include files (default) ; $bFilterIncl = 0 ; Exclude files ; ; $iView - Specifies icon view mode, default is $FVM_DETAILS ; $FVM_ICON = 1 ; The view should display medium-size (48x48) icons. ; $FVM_SMALLICON = 2 ; The view should display small icons. ; $FVM_LIST = 3 ; Object names are displayed in a list view. ; $FVM_DETAILS = 4 ; Object names and other selected information, such as the size or date last updated, are shown. ; $FVM_TILE = 6 ; The view should display large icons. ; $FVM_CONTENT = 8 ; Windows 7 and later. The view should display content mode. ; $FVM_LARGE = 9 ; The view should display large (96x96) icons. ; $FVM_EXTRALARGE = 10 ; The view should display extra large (256x256) icons. ; ; $iDesktopView - Specifies icon view mode for the Desktop, default is $FVM_ICON ; $iDesktopView = 0 ; This will set $iDesktopView = $iView ; ; Examples: ; ExplorerWindowCreate( 0, 0, 0, 0, $hGui, "", "C:\Windows" ) ; ExplorerWindowCreate( 0, 0, 0, 0, $hGui, "", @ScriptDir, 0, "", 1, $FVM_DETAILS, $FVM_ICON ) ;1. Basic exampleThis example contains the least amount of code, and is suitable for testing purposes. The Explorer right pane fills out the entire GUI window, which doesn't contain any other controls.2. Position and sizeLeft, top, width and height parameters are used to position Explorer in middle of the GUI window. This creates margins on all four sides. The margins can be used for buttons or other controls. If you want to use the Explorer in your own program, you can copy this example.3. Navigation buttonsThis is a copy of example 2. Two navigation buttons are added in top of GUI.4. Toolbar exampleThe example demonstrates how to implement various features. E.g. how to browse to the previous and parent folder. And how to set icon view modes with both the View button and the context menu. Note that the view modes in the View button and the context menu are completely integrated. A view mode set with the button, is reflected in the context menu. And vice versa.5. Context menuTwo custom items are added to the context menu. The example is prepared for deletion and disabling of context menu items.6. Cut-copy-pasteThree buttons are created to execute Cut, Copy and Paste commands in the context menu. The buttons are completely integrated with the context menu. You can copy with the button, and paste with the context menu. And vice versa. You can undo the Paste command with Ctrl+Z.Other examples (Vista and later) in posts below:Three examples where all panes are implemented (not just the right pane)You can find an example which implements the other panes in this post.This example shows how to merge all include files into a single Include folder.Implement proper tab order between LV and TV, and update LV on up/down keys in TV here.An example that shows how to cancel drag/drop operations can be found here. AutoIt 3.3.8If you want to run the scripts on AutoIt 3.3.8 you need APIConstants.au3 and WinAPIEx.au3 by Yashied. The UDFs are not included in the zip. You must enable the UDFs in top of ShellFunctions.au3. The UDFs are already added, but commented out. And you must comment out the 3.3.10 UDFs in ShellFunctions.au3 and WERPFuncs.au3. Testet on XP 32 bit and Win 7 32/64 bit. The scripts can be run as both 32 and 64 bit programs. If you are running a 64 bit Windows you should run the scripts as 64 bit programs.Windows Explorer right pane.7z Edited May 29, 2015 by LarsJ Added list of examples in posts below KLM, Zmy, JohnOne and 7 others 9 1 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
KaFu Posted November 28, 2013 Share Posted November 28, 2013 From a fist quick look I would say... this is a most excellent example , keep em coming! OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Bluesmaster Posted December 1, 2013 Share Posted December 1, 2013 This is very usefull as it really provides the full functionality of the windows explorer. Unfortunately I receive a com-error when resizting. 80020010 (DISP_E_BADCALLEE) http://msdn.microsoft.com/en-us/library/windows/desktop/dd542644(v=vs.85).aspx Maybe wrong parameter types? I tried some things but couldnt fix it. Could you have a short look on this? ( windows 8, x64 ) Here is the com-error handler I used $oMyError = ObjEvent( "AutoIt.Error" , "comErrorHandler" ) ; Initialize a COM error handler Func comErrorHandler() ConsoleWrite( "We intercepted a COM Error !" & @CRLF & @CRLF & _ "err.description is: " & @TAB & $oMyError.description & @CRLF & _ "err.windescription:" & @TAB & $oMyError.windescription & @CRLF & _ "err.number is: " & @TAB & hex($oMyError.number,8) & @CRLF & _ "err.lastdllerror is: " & @TAB & $oMyError.lastdllerror & @CRLF & _ "err.scriptline is: " & @TAB & $oMyError.scriptline & @CRLF & _ "err.source is: " & @TAB & $oMyError.source & @CRLF & _ "err.helpfile is: " & @TAB & $oMyError.helpfile & @CRLF & _ "err.helpcontext is: " & @TAB & $oMyError.helpcontext _ ) Endfunc Thank you so much Bluesmaster My UDF: [topic='156155']_shellExecuteHidden[/topic] Link to comment Share on other sites More sharing options...
LarsJ Posted December 1, 2013 Author Share Posted December 1, 2013 Yes, this is not the usual listview. This is a real Windows Explorer. But only the right pane. All the functionality of Windows Explorer is working. E.g. keyboard shortcuts, the context (right click) menu, cut, copy, paste, drag & drop and automatic update of the window (if you create and save a new file in Scite the window is updated automatically, you don't even have to press F5).Error when resizingI get no errors on Windows 7 x64. I'm not able to test on Windows 8. So I can only be guessing.Try to comment out this line$oIExplorerBrowser.SetRect( $NULL, DllStructGetPtr( $tRECT ) )in function WM_SIZING in the bottom of "Windows Explorer right pane - Vista, Win 7.au3" to verify that the error disappears.If the error disappears then enable the above line again and replace these lines$tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT, "Left", 0 ) DllStructSetData( $tRECT, "Top", $aTBsize[1] + 6 ) DllStructSetData( $tRECT, "Right", $w ) DllStructSetData( $tRECT, "Bottom", $h ) WinMove( $hToolbar, "", 0, 0, $w, $aTBsize[1] ) $oIExplorerBrowser.SetRect( $NULL, DllStructGetPtr( $tRECT ) )with these lines.Local Static $tRECT2 = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT2, "Left", 0 ) DllStructSetData( $tRECT2, "Top", $aTBsize[1] + 6 ) DllStructSetData( $tRECT2, "Right", $w ) DllStructSetData( $tRECT2, "Bottom", $h ) WinMove( $hToolbar, "", 0, 0, $w, $aTBsize[1] ) $oIExplorerBrowser.SetRect( $NULL, DllStructGetPtr( $tRECT2 ) )The Static keyword secures that the pointer to $tRECT2 is still valid when the function exits. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Bluesmaster Posted December 2, 2013 Share Posted December 2, 2013 (edited) Oh hello LarsJ, I firstly did not recognize that this great piece of code is also your work Unfortunately it does not work with the static pointer. It does not even work on my win 7 virtual machine??? My Autoit version is v3.3.8.1 As I do not know any better for now I compiled it and appended the file. This could be a starting point to figure out the differences between our systems. (I would never include any malicious code but anyway you should use a vm too) Maybe you could do the same, I would really like to use this great code but need the resizing. best regards Bluesmaster Windows Explorer right pane.rar Edited December 2, 2013 by Bluesmaster My UDF: [topic='156155']_shellExecuteHidden[/topic] Link to comment Share on other sites More sharing options...
LarsJ Posted December 2, 2013 Author Share Posted December 2, 2013 Bluesmaster, Are you running a 32 bit Explorer on a 64 bit system? This can not be done as I have written in the last line of the first post just above the download link. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Bluesmaster Posted December 3, 2013 Share Posted December 3, 2013 I read it. And I could swear I had implemented "#AutoIt3Wrapper_UseX64=y". But you are right, it seems as I had forgotten it. Its also a bit mysterious to my why the "Initialize" - method tolerates that mistake and the "SetRect" method does not But anyway: Sorry for my mistake and thank you for the hint. Bluesmaster My UDF: [topic='156155']_shellExecuteHidden[/topic] Link to comment Share on other sites More sharing options...
KaFu Posted December 3, 2013 Share Posted December 3, 2013 In ICU I use something like this to prevent this kind of error.If @OSArch = "X64" And Not @AutoItX64 Then MsgBox(16, "Fatal Error", "This software runs as a 32bit program and will not run correctly on a 64bit OS.") Exit ElseIf @OSArch <> "X64" And @AutoItX64 Then MsgBox(16, "Fatal Error", "This software runs as a 64bit program and will not run correctly on a 32bit OS.") Exit EndIf OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2024-Oct-13) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Oct-13) HMW - Hide my Windows (2024-Oct-19) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2024-Oct-20) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
Phillipe Posted February 27, 2014 Share Posted February 27, 2014 Hi; There is a easy way to implement the windows explorer window in my own autoit program? I try to create a udf to call one single line to create the window but ive got too much const errors. Can you help me out? thanks! by the way, i think this is the most perfect way to show it. Link to comment Share on other sites More sharing options...
Bluesmaster Posted February 27, 2014 Share Posted February 27, 2014 (edited) I once started to do that. I use the "xp-version" because it uses the good old syslistview32 which can be automated more easy. explorerRightPaneUDF.au3 Its not only 1 function because the interface need some callbacks-stubs but its ok. All tributes go the amazing LarsJ. I will never understand how he has figured out all those miles of constants and interface definitions best regards Blues Edited February 27, 2014 by Bluesmaster My UDF: [topic='156155']_shellExecuteHidden[/topic] Link to comment Share on other sites More sharing options...
Phillipe Posted February 28, 2014 Share Posted February 28, 2014 I once started to do that. I use the "xp-version" because it uses the good old syslistview32 which can be automated more easy. Thanks Blues; I will try with your example! best regards! Link to comment Share on other sites More sharing options...
Phillipe Posted February 28, 2014 Share Posted February 28, 2014 Blues; I got it! thank you, do you know which functions that sets the preferences for this options? - Open folder on the same window; - change the view type ( Details, list, small, medium, large icons); - change the path folder with a button ( i try to use the "ToolbarFunctions.au3" but no luck). Thank you a lot! Link to comment Share on other sites More sharing options...
LarsJ Posted February 28, 2014 Author Share Posted February 28, 2014 What a lot of activity. I like that.Phillipe, I do not have time right now, but I will come back with an answer tomorrow, if Bluesmaster or somebody else hasn't answered. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Bluesmaster Posted March 1, 2014 Share Posted March 1, 2014 Hi, unfortunately I cannot answer all questions. Viewtype is easy: DllStructSetData( $tFOLDERSETTINGS, "ViewMode", 1 ) ; 1 = medium 2 = small | 3 = list | 4 = details | 5 = thumbnail| 6 = large | 7 = filmstrip Renavigation must be done with ... $oIShellBrowser.BrowseObject( $pidlRel , 1 ) ; 0 = default user setting | 1 = open folders in same window | 2 = open folders in new window ...I think. But I dont know how to get the oIShellBrowser object I just got the pIShellBrowser This must solve the first question too through the 2. parameter if we get this to run ehm....LarsJ ? new more simplified code: expandcollapse popup#include "WinAPIEx.au3" global $hHook, $oIShellView, $hGui, $hExplorer HotKeySet("{ESC}", "_Exit") Func _Exit() _WinAPI_UnhookWindowsHookEx( $hHook ) $oIShellView = 0 Exit EndFunc explorerRightPane() While Sleep( 1000 ) WEnd Func explorerRightPane( $path = @ScriptDir , $x = 100 , $y = 100 , $width = 500 , $height = 500) ; 1 - CONSTANTS global $sIID_IServiceProvider = "{6D5140C1-7436-11CE-8034-00AA006009FA}" $dtag_IServiceProvider = "QueryService hresult(ptr;ptr;ptr*);" $tagMSG = "hwnd hwnd;uint message;wparam wParam;lparam lParam;dword time;int X;int Y" global $sIID_ICommDlgBrowser = "{000214F1-0000-0000-C000-000000000046}" $dtag_ICommDlgBrowser = "OnDefaultCommand hresult(ptr);OnStateChange hresult(ptr;ulong);IncludeObject hresult(ptr;ptr);" $dtag_IOleWindow = "GetWindow hresult(hwnd*);ContextSensitiveHelp hresult(int);" $sIID_IShellFolder = "{000214E6-0000-0000-C000-000000000046}" $tRIID_IShellFolder = _WinAPI_GUIDFromString( $sIID_IShellFolder ) $dtag_IShellFolder = "ParseDisplayName hresult(hwnd;ptr;wstr;ulong*;ptr*;ulong*);EnumObjects hresult(hwnd;dword;ptr*);BindToObject hresult(ptr;ptr;clsid;ptr*);BindToStorage hresult(ptr;ptr;clsid;ptr*);CompareIDs hresult(lparam;ptr;ptr);CreateViewObject hresult(hwnd;clsid;ptr*);GetAttributesOf hresult(uint;struct*;ulong*);GetUIObjectOf hresult(hwnd;uint;struct*;clsid;uint*;ptr*);GetDisplayNameOf hresult(ptr;dword;struct*);SetNameOf hresult(hwnd;ptr;wstr;dword;ptr*);" $sIID_IShellBrowser = "{000214E2-0000-0000-C000-000000000046}" $dtag_IShellBrowser = $dtag_IOleWindow &"InsertMenusSB hresult(handle;ptr);SetMenuSB hresult(handle;handle;hwnd);RemoveMenusSB hresult(handle);SetStatusTextSB hresult(ptr);EnableModelessSB hresult(int);TranslateAcceleratorSB hresult(ptr;word);BrowseObject hresult(ptr;uint);GetViewStateStream hresult(dword;ptr*);GetControlWindow hresult(uint;hwnd);SendControlMsg hresult(uint;uint;wparam;lparam;lresult);QueryActiveShellView hresult(ptr*);OnViewWindowActive hresult(ptr);SetToolbarItems hresult(ptr;uint;uint);" $sIID_IShellView = "{000214E3-0000-0000-C000-000000000046}" $tRIID_IShellView = _WinAPI_GUIDFromString( $sIID_IShellView ) $dtag_IShellView = $dtag_IOleWindow & "TranslateAccelerator hresult(ptr);EnableModeless hresult(int);UIActivate hresult(uint);Refresh hresult();CreateViewWindow hresult(ptr;ptr;ptr;ptr;hwnd*);DestroyViewWindow hresult();GetCurrentInfo hresult(ptr*);AddPropertySheetPages hresult(dword;ptr;lparam);SaveViewState hresult();SelectItem hresult(ptr;uint);GetItemObject hresult(uint;struct*;ptr*);" $tagFOLDERSETTINGS = "uint ViewMode;uint fFlags" DllCall("ole32.dll", "long", "OleInitialize", "ptr", 0) ; 2 - GUI ( Wrapper ) $hGui = GUICreate( "" , $width, $height, $x, $y) ; $WS_POPUP = 0x80000000 GUISetState( @SW_SHOW, $hGui ) Local $hMessageFilter ; , $hHook ; Catch window messages $hMessageFilter = DllCallbackRegister( "boxCallbacks", "long", "int;wparam;lparam" ) $hHook = _WinAPI_SetWindowsHookEx( $WH_GETMESSAGE , DllCallbackGetPtr( $hMessageFilter ) , 0 , _WinAPI_GetCurrentThreadId() ) ; 3 - START DIR + SIZE Local $pDesktopFolder $aRet = DllCall( "shell32.dll", "uint", "SHGetDesktopFolder", "ptr*", 0 ) $pDesktopFolder = $aRet[1] $oIDesktopFolder = ObjCreateInterface( $pDesktopFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; $oIDesktopFolder is used in oIShellBrowser_BrowseObject because the PIDLs are absolute PIDLs. This means that they are relative to the Desktop (and not the parent folder). Local $pParentFolder, $pidlRel, $pFolder $pPidlHome = DllCall( "shell32.dll", "ptr", "ILCreateFromPathW", "wstr", $path )[0] $aRet = DllCall( "shell32.dll", "long", "SHBindToParent", "ptr", $pPidlHome, "ptr", DllStructGetPtr( $tRIID_IShellFolder ), "ptr*", 0, "ptr*", 0 ) $pParentFolder = $aRet[3] $pidlRel = $aRet[4] $oIShellFolder = ObjCreateInterface( $pParentFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Parent folder $oIShellFolder.BindToObject( $pidlRel, 0x00000000 , $tRIID_IShellFolder, $pFolder ) ; $NULL = 0x00000000 $oIShellFolder = ObjCreateInterface( $pFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; @ScriptDir $aPos = WinGetClientSize( $hGui ) $tRECT = DllStructCreate( $tagRECT ) DllStructSetData( $tRECT , "Left" , 0 ) DllStructSetData( $tRECT , "Top" , 0 ) DllStructSetData( $tRECT , "Right" , $aPos[0] ) DllStructSetData( $tRECT , "Bottom" , $aPos[1] ) ; 4 - SHELL BROWSER Local $pShellView $oIShellFolder.CreateViewObject( $hGui, $tRIID_IShellView, $pShellView ) $oIShellView = ObjCreateInterface( $pShellView, $sIID_IShellView, $dtag_IShellView ) $dtag_IShellBrowser = "QueryInterface hresult(ptr;ptr*);AddRef ulong();Release ulong();" & $dtag_IShellBrowser ; Inherits from IUnknown $pIShellBrowser = DllCall('ole32.dll', 'ptr', 'CoTaskMemAlloc', 'uint_ptr', 152 )[0] ; $AllocSize = $PtrSize * (18 + 1) = 8 * 19 = 152 $tInterface = DllStructCreate( "ptr[" & 18 + 1 & "]", $pIShellBrowser ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr( DllCallbackRegister( "oIShellBrowser_QueryInterface" , "long" , "ptr;ptr;ptr*" )) , 2 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_AddRef" , "ulong" , "ptr" )) , 3 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_Release" , "ulong" , "ptr" )) , 4 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_GetWindow" , "long" , "ptr;hwnd*" )) , 5 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr( DllCallbackRegister( "oIShellBrowser_InsertMenusSB" , "long" , "ptr;handle;ptr" )) , 7 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_SetMenuSB" , "long" , "ptr;handle;handle;hwnd" )) , 8 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_RemoveMenusSB" , "long" , "ptr;handle" )) , 9 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_BrowseObject" , "long" , "ptr;ptr;uint" )) , 13 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_GetControlWindow" , "long" , "ptr;uint;hwnd" )) , 15 ) DllStructSetData( $tInterface , 1, DllCallbackGetPtr(DllCallbackRegister( "oIShellBrowser_OnViewWindowActive" , "long" , "ptr;ptr" )) , 18 ) DllStructSetData( $tInterface , 1 , $pIShellBrowser + 8 ) ; Interface method pointers are actually pointer size away ; 5 - WINDOW $tFOLDERSETTINGS = DllStructCreate( $tagFOLDERSETTINGS ) DllStructSetData( $tFOLDERSETTINGS, "ViewMode", 1 ) ; 1 = medium 2 = small | 3 = list | 4 = details | 5 = thumbnail| 6 = large | 7 = filmstrip DllStructSetData( $tFOLDERSETTINGS, "fFlags" , 0x00800000 ) ;$FWF_NOCOLUMNHEADER = 0x00800000 > sorgt auch für frei verschiebbare Elemente $hViewWindow = $oIShellView.CreateViewWindow( 0x00000000 , DllStructGetPtr( $tFOLDERSETTINGS ), $pIShellBrowser, DllStructGetPtr( $tRECT ), $hExplorer ) ; $NULL = 0x00000000 ConsoleWrite( $hViewWindow ) $oIShellView.UIActivate( 1 ) ; $SVUIA_ACTIVATE_NOFOCUS = 1 ; 6 - REBROWSE (experiments, no success so far) Sleep( 2000 ) ;~ Local $pParentFolder, $pidlRel, $pFolder ;~ $pPidlHome = DllCall( "shell32.dll", "ptr", "ILCreateFromPathW", "wstr", "c:\" )[0] ;~ $aRet = DllCall( "shell32.dll", "long", "SHBindToParent", "ptr", $pPidlHome, "ptr", DllStructGetPtr( $tRIID_IShellFolder ), "ptr*", 0, "ptr*", 0 ) ;~ $pParentFolder = $aRet[3] ;~ $pidlRel = $aRet[4] ;~ $oIShellFolder = ObjCreateInterface( $pParentFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Parent folder ;~ $oIShellFolder.BindToObject( $pidlRel, 0x00000000 , $tRIID_IShellFolder, $pFolder ) ; $NULL = 0x00000000 ; http://msdn.microsoft.com/en-us/library/windows/desktop/bb775113(v=vs.85).aspx ;~ $oIShellFolder = ObjCreateInterface( $pIShellBrowser, $sIID_IShellBrowser , $dtag_IShellBrowser ) ; Parent folder ;~ $oIShellBrowser.BrowseObject( $pidlRel , 1 ) ; 0 = default user setting | 1 = open folders in same window | 2 = open folders in new window ;~ Global Const $SBSP_DEFBROWSER = 0x0000 ; 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. ;~ Global Const $SBSP_SAMEBROWSER = 0x0001 ; Browse to another folder with the same Windows Explorer window. ;~ Global Const $SBSP_NEWBROWSER = 0x0002 ; Creates another window for the specified folder. EndFunc ; CALLBACKS (IShellBrowser) Func oIShellBrowser_GetWindow( $pSelf, $hExplorer ) DllStructSetData( DllStructCreate( "hwnd", $hExplorer ) , 1 , $hGui ) ; belege den DLL-Struct mit dem zugehörigen windowhandle ( $hExplorer ist der Pointer der auf dass DLL struct zeigen muss ) EndFunc Func oIShellBrowser_QueryInterface( $pSelf, $pRIID, $pObj ) Return 0x80004002 ; $E_NOINTERFACE = 0x80004002 EndFunc Func oIShellBrowser_AddRef( $pSelf ) EndFunc Func oIShellBrowser_Release( $pSelf ) EndFunc Func oIShellBrowser_InsertMenusSB( $pSelf, $hmenuShared, $lpMenuWidths ) EndFunc Func oIShellBrowser_GetControlWindow( $pSelf, $id, $lphwnd ) EndFunc Func oIShellBrowser_OnViewWindowActive( $pSelf, $ppshv ) EndFunc Func oIShellBrowser_SetMenuSB( $pSelf, $hmenuShared, $holemenuRes, $hwndActiveObject ) EndFunc Func oIShellBrowser_RemoveMenusSB( $pSelf, $hmenuShared ) EndFunc Func oIShellBrowser_BrowseObject( $pidl, $wFlags ) EndFunc Phillipe 1 My UDF: [topic='156155']_shellExecuteHidden[/topic] Link to comment Share on other sites More sharing options...
LarsJ Posted March 1, 2014 Author Share Posted March 1, 2014 (edited) I have not gone ahead with the scripts by Bluesmaster. Instead I have moved most code from the start script to an UDF: WindowsExplorer.au3.This is the new start script (included in the zip):expandcollapse popup#include <GuiConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> Opt( "MustDeclareVars", 1 ) ; Project includes #include "Resources\Include\WindowsExplorer.au3" ; Include this file #include "Resources\Include\ToolbarFunctions.au3" ; Edit this file to modify toolbar MainFunc() Func MainFunc() ; Create GUI Local $sTitle = "Windows Explorer right pane" Local $iStyle = BitOR( $GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_MAXIMIZEBOX, $WS_SIZEBOX ) Local $hGui = GUICreate( $sTitle, 700, 400, 200, 50, $iStyle ) ; Show GUI GUISetState( @SW_SHOW, $hGui ) ; Create toolbar ; CreateToolbar( $hGui, $bLargeIcons = False ) CreateToolbar( $hGui, True ) ; Create Explorer window ; CreateExplorerWindow( $hGui, $sFolder = @ScriptDir, $iView = $FVM_DETAILS ) ; $FVM_ICON = 1 ; The view should display medium-size icons. ; $FVM_SMALLICON = 2 ; The view should display small icons. ; $FVM_LIST = 3 ; Object names are displayed in a list view. ; $FVM_DETAILS = 4 ; Object names and other selected information, such as the size or date last updated, are shown. ; $FVM_THUMBNAIL = 5 ; The view should display thumbnail icons. ; $FVM_TILE = 6 ; The view should display large icons. ; $FVM_THUMBSTRIP = 7 ; The view should display icons in a filmstrip format. ;CreateExplorerWindow( $hGui, "C:\Windows", $FVM_ICON ) CreateExplorerWindow( $hGui ) ; Message loop Local $iMsg While 1 $iMsg = GUIGetMsg() If $iMsg = 0 Or $iMsg = $GUI_EVENT_MOUSEMOVE Then ContinueLoop Switch $iMsg Case $idToolbarClick, $idDropDownMenu, $idBackMenu, $idViewMenu ToolbarEvent( $iMsg ) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd EndFuncThis code doesn't work on XP, and you need AutoIt 3.3.10.0+ (however, only a matter of a few includes).Let me know if there are any issues.Windows Explorer right pane.7z Edited March 2, 2014 by LarsJ KLM and Phillipe 2 Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Inververs Posted March 1, 2014 Share Posted March 1, 2014 LarsJ, content disappears when you change the window size. i think it is issue. Link to comment Share on other sites More sharing options...
LarsJ Posted March 1, 2014 Author Share Posted March 1, 2014 Are you running af 32 bit Explorer on a 64 bit Windows? This can not be done. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Inververs Posted March 2, 2014 Share Posted March 2, 2014 32 bits all. Windows 7. Link to comment Share on other sites More sharing options...
LarsJ Posted March 2, 2014 Author Share Posted March 2, 2014 Inververs, You are absolutely right. There is an issue when the window is resized. The faulty code is in the SetRect method of the ExplorerBrowser object in function WM_SIZING in bottom of WindowsExplorer.au3. It has something to do with differences in parameter passing on 32 and 64 bit systems. The problem is fixed in the new zip in post #15.Note that this issue also exists in the zip in first post. And I have noticed a few other minor issues. I will update the zip. Hopefully within a relatively short time. Controls, File Explorer, ROT objects, UI Automation, Windows Message MonitorCompiled code: Accessing AutoIt variables, DotNet.au3 UDF, Using C# and VB codeShell menus: The Context menu, The Favorites menu. Shell related: Control Panel, System Image ListsGraphics related: Rubik's Cube, OpenGL without external libraries, Navigating in an image, Non-rectangular selectionsListView controls: Colors and fonts, Multi-line header, Multi-line items, Checkboxes and icons, Incremental searchListView controls: Virtual ListViews, Editing cells, Data display functions Link to comment Share on other sites More sharing options...
Bluesmaster Posted March 3, 2014 Share Posted March 3, 2014 @Lars can you have a look at the code in #14 when you have some time then? You dont really have to read it all. The issue is just point 6. where we need oIShellBrowser from pIShellBrowser to renavigate/ navigate in place But dont hurry best regards Blues My UDF: [topic='156155']_shellExecuteHidden[/topic] Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now