Zachlr Posted November 7, 2009 Posted November 7, 2009 I'm looking to embed an MS explorer (or similar) pane in a GUI, with which the script can interact (get file paths of selected items). FileOpenDialogue() would be a cheap shortcut, and making my own embedded file explorer would be a project in itself. I hope someone can point me in the right direction. Thanks, Zach
Moderators Melba23 Posted November 7, 2009 Moderators Posted November 7, 2009 Zachlr, Lots of ideas here. M23 Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Mat Posted November 7, 2009 Posted November 7, 2009 (edited) A few more improvements to that thread (I think) expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Opt("WinTitleMatchMode", 4) Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "C:\" Global $iWidth = 320, $iHeight = 460 ; Create the (left) Explorer GUI $hExplHolder = GUICreate("Explorer", $iWidth + 300, $iHeight, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_SIZEBOX), 0x00000010) Run('explorer.exe /n, "' & $sStartDir & '"') WinWait("[CLASS:CabinetWClass]") $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") WinSetState($hExplorer, "", @SW_HIDE) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) _WinAPI_SetParent($hExplorer, $hExplHolder) _WinAPI_SetWindowLong($hExplorer, $GWL_STYLE, -1064828928) ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "ViewChange", "list") $hList = GUICtrlCreateListView ("File", $iWidth + 4, 4, 292, 200, 0x0003 + 0x0008 + 0x0004) GUICtrlSetState (-1, 8) WinSetState($hExplorer, "", @SW_SHOW) GUISetState(@SW_SHOW, $hExplHolder) While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case -13 GUICtrlCreateListViewItem (@GUI_DRAGFILE, $hList) EndSwitch WEnd Mat Edit: With no resizing though... Edited November 7, 2009 by Mat AutoIt Project Listing
Zachlr Posted November 7, 2009 Author Posted November 7, 2009 Thanks for the example, Mat. In fact, no resizing/moving works in my favor for this project. The problem is, I can't see any direct way of getting the selected file. Moving it to the listbox would work, but I'd really like to be able to get the selected file(s) location when a toolbar button is clicked, for example. If you could help me out with this, I'd really appreciate it. Thanks, Zach
Mat Posted November 7, 2009 Posted November 7, 2009 (edited) ControlListView should do what you want, I'll throw together an example for you soon. It is fairly self explanatory. Mat Edit: expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Opt("WinTitleMatchMode", 4) Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "C:\" Global $iWidth = 320, $iHeight = 460 ; Create the (left) Explorer GUI $hExplHolder = GUICreate("Explorer", $iWidth + 300, $iHeight, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_SIZEBOX), 0x00000010) Run('explorer.exe /n, "' & $sStartDir & '"') WinWait("[CLASS:CabinetWClass]") $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") WinSetState($hExplorer, "", @SW_HIDE) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) _WinAPI_SetParent($hExplorer, $hExplHolder) _WinAPI_SetWindowLong($hExplorer, $GWL_STYLE, -1064828928) ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "ViewChange", "list") ;$hList = GUICtrlCreateListView ("File", $iWidth + 4, 4, 292, 200, 0x0003 + 0x0008 + 0x0004) ;GUICtrlSetState (-1, 8) $hBtn = GUICtrlCreateButton ("Get selected!", $iWidth + 4, 4, 80, 20) WinSetState($hExplorer, "", @SW_SHOW) GUISetState(@SW_SHOW, $hExplHolder) Local $msg, $sSel, $sRet, $aItems While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case $hBtn $sSel = ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetSelected", 1) If StringInStr ($sSel, "|") Then ; Multiple selected items $sRet = "" $aItems = StringSplit ($sSel, "|") For $i = 1 to $aItems[0] $sRet &= ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $aItems[$i], 0) & @CRLF Next Else $sRet = ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $sSel, 0) EndIf MsgBox (0, "", $sRet) ;Case -13 ; GUICtrlCreateListViewItem (@GUI_DRAGFILE, $hList) EndSwitch WEnd Edited November 7, 2009 by Mat AutoIt Project Listing
Moderators Melba23 Posted November 7, 2009 Moderators Posted November 7, 2009 Mat,Thanks for that nice example.M23P.S. Where did you come across the "applaud/money" quote? Last time I heard that was from Mike Portnoy with Transatlantic at 013 in Tilburg - however, I would be willing to bet that was not where you got it from! Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind Open spoiler to see my UDFs: Spoiler ArrayMultiColSort ---- Sort arrays on multiple columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area
Mat Posted November 7, 2009 Posted November 7, 2009 If you ever get the chance to visit the tate, it's amazing. Round the back is the "Monument to the Unknown Artist". The front has a plaque with a Latin phrase: "Non plaudite. Modo pecuniam jacite.", I just had to google the latin when I got back, it made me laugh so much. http://londondailyphoto.blogspot.com/2009/09/dont-applaud-just-throw-your-money.html back on subject, I am working on hiding the Rebar for the explorer, but can't seem to resize the listview. If anyone has any ideas on that it would be very nice Mat AutoIt Project Listing
Zachlr Posted November 7, 2009 Author Posted November 7, 2009 Thank you very much for the example. It'll work just fine for my program. I didn't know the explorer pane could be treated as a regular ListViews.
Mat Posted November 8, 2009 Posted November 8, 2009 (edited) Thank you very much for the example. It'll work just fine for my program. I didn't know the explorer pane could be treated as a regular ListViews. Good to know its working, the only bug you might want to look at is when no items are selected, it passes the first one to you. No progress for me on hiding the rebar, I have a possible method, but I have a funny feeling it will change some settings for proper explorer windows. If I get it working accurately I might even post it in example scripts. Mat Edit: This is my next attempt...expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Opt("WinTitleMatchMode", 4) Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "C:\" Global $iWidth = 320, $iHeight = 460 ; Create the Explorer GUI $hExplHolder = GUICreate("Explorer", $iWidth + 300, $iHeight, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_SIZEBOX), 0x00000010) Run('explorer.exe /n, "' & $sStartDir & '"') WinWait("[CLASS:CabinetWClass]") $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") WinSetState($hExplorer, "", @SW_HIDE) $hList = ControlGetHandle ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]") ControlListView ($hExplorer, "", $hList, "ViewChange", "list") _WinAPI_SetParent($hList, $hExplHolder) WinMove ($hList, "", 2, 2, $iWidth, $iHeight) $hBtn = GUICtrlCreateButton ("Get selected!", $iWidth + 4, 4, 80, 20) GUISetState(@SW_SHOW, $hExplHolder) Local $msg, $sSel, $sRet, $aItems While 1 $msg = GUIGetMsg() Switch $msg Case -3 ExitLoop Case $hBtn $sSel = ControlListView ($hExplHolder, "", $hList, "GetSelected", 1) If StringInStr ($sSel, "|") Then ; Multiple selected items $sRet = "" $aItems = StringSplit ($sSel, "|") For $i = 1 to $aItems[0] $sRet &= ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $aItems[$i], 0) & @CRLF Next Else $sRet = ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $sSel, 0) EndIf MsgBox (0, "", $sRet) EndSwitch WEnd WinClose ($hExplorer) No context menus, they appear to be handled by the window itself. It does mean you could potentially set your own context menu to it, though I am unsure how I might go about that. Basically, it deals only with the listview, and steals it off the explorer window. I think this is as good as its going to get at the moment Edited November 8, 2009 by Mat AutoIt Project Listing
Zachlr Posted November 8, 2009 Author Posted November 8, 2009 Good to know its working, the only bug you might want to look at is when no items are selected, it passes the first one to you. No progress for me on hiding the rebar, I have a possible method, but I have a funny feeling it will change some settings for proper explorer windows. If I get it working accurately I might even post it in example scripts. Mat Edit: This is my next attempt...expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Opt("WinTitleMatchMode", 4) Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "C:\" Global $iWidth = 320, $iHeight = 460 ; Create the Explorer GUI $hExplHolder = GUICreate("Explorer", $iWidth + 300, $iHeight, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_SIZEBOX), 0x00000010) Run('explorer.exe /n, "' & $sStartDir & '"') WinWait("[CLASS:CabinetWClass]") $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") WinSetState($hExplorer, "", @SW_HIDE) $hList = ControlGetHandle ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]") ControlListView ($hExplorer, "", $hList, "ViewChange", "list") _WinAPI_SetParent($hList, $hExplHolder) WinMove ($hList, "", 2, 2, $iWidth, $iHeight) $hBtn = GUICtrlCreateButton ("Get selected!", $iWidth + 4, 4, 80, 20) GUISetState(@SW_SHOW, $hExplHolder) Local $msg, $sSel, $sRet, $aItems While 1 $msg = GUIGetMsg() Switch $msg Case -3 ExitLoop Case $hBtn $sSel = ControlListView ($hExplHolder, "", $hList, "GetSelected", 1) If StringInStr ($sSel, "|") Then ; Multiple selected items $sRet = "" $aItems = StringSplit ($sSel, "|") For $i = 1 to $aItems[0] $sRet &= ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $aItems[$i], 0) & @CRLF Next Else $sRet = ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $sSel, 0) EndIf MsgBox (0, "", $sRet) EndSwitch WEnd WinClose ($hExplorer) No context menus, they appear to be handled by the window itself. It does mean you could potentially set your own context menu to it, though I am unsure how I might go about that. Basically, it deals only with the listview, and steals it off the explorer window. I think this is as good as its going to get at the moment Hi, I really like this script. I like how it shows just the list view, but it doesn't have a path field. I suppose you could use a separate control, such as a combo box or input, as a path field, but I wouldn't know how to send that information to the list view. Additionally, the lack of a context menu isn't really a problem, and being able to make a custom context menu would be great. Unfortunately, when I ran that script, I noticed some problems. The Get Selected button seems to display 0, regardless of the selection. Moreover, the Get Selection button causes the GUI to "freak out;" rapidly activating and deactivating the window. In addition, once a folder is double clicked, it disappears, and seems to cause other items to disappear when moused-over. Again, thanks for providing this code. I really like the concept, but like I said, it has some bugs, and I wouldn't know how to fix them. I hope you can get everything working. Thanks, Zach
Mat Posted November 8, 2009 Posted November 8, 2009 There is definitely some problems in there with the listview, and its not acting very logically... I am working on it, but there are a lot of problems to overcome conceptually before I even begin fine tuning it. as for double clicking, its redrawing the window:expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Opt("WinTitleMatchMode", 4) Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "C:\" Global $iWidth = 320, $iHeight = 460 ; Create the Explorer GUI $hExplHolder = GUICreate("Explorer", $iWidth + 300, $iHeight, Default, Default, BitOR($GUI_SS_DEFAULT_GUI, $WS_CLIPCHILDREN, $WS_SIZEBOX), 0x00000010) Run('explorer.exe /n, "' & $sStartDir & '"') WinWait("[CLASS:CabinetWClass]") $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") ;WinSetState($hExplorer, "", @SW_HIDE) $hList = ControlGetHandle ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]") ControlListView ($hExplorer, "", $hList, "ViewChange", "list") _WinAPI_SetParent($hList, $hExplHolder) WinMove ($hList, "", 2, 2, $iWidth, $iHeight) $hBtn = GUICtrlCreateButton ("Get selected!", $iWidth + 4, 4, 80, 20) GUISetState(@SW_SHOW, $hExplHolder) Local $msg, $sSel, $sRet, $aItems While 1 $msg = GUIGetMsg() Switch $msg Case -3 ExitLoop Case $hBtn $sSel = ControlListView ($hExplHolder, "", $hList, "GetSelected", 1) If StringInStr ($sSel, "|") Then ; Multiple selected items $sRet = "" $aItems = StringSplit ($sSel, "|") For $i = 1 to $aItems[0] $sRet &= ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $aItems[$i], 0) & @CRLF Next Else $sRet = ControlListView ($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "GetText", $sSel, 0) EndIf MsgBox (0, "", $sRet) EndSwitch WEnd WinClose ($hExplorer) As said, work is being done on it. Mat AutoIt Project Listing
Zachlr Posted November 8, 2009 Author Posted November 8, 2009 Yeah, I understand. I'm glad you're continuing to work on it though . It's a great script. I'll just have to use the full embedded window for now, but I'll keep my eye out for the finished product, if you do decide to release it in the example forum. The script you posted above didn't seem to fix the problem. Are you saying that the window must be shown in order for it to correctly redraw the AutoIt GUI? Thanks, Zach
Mat Posted November 9, 2009 Posted November 9, 2009 No... That code just showed the problem a lot more clearly. I only commented out a line AutoIt Project Listing
Zachlr Posted November 9, 2009 Author Posted November 9, 2009 No... That code just showed the problem a lot more clearly. I only commented out a line Ah, my mistake.
Morronic Posted April 12, 2014 Posted April 12, 2014 expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <WinAPI.au3> #include <Constants.au3> Opt("WinTitleMatchMode", 4) Global $hMigration, $hExplHolder, $hExplorer, $sStartDir = "C:\" Global $iWidth = @DesktopWidth - 200, $iHeight = @DesktopHeight - 200 ; Create the (left) Explorer GUI $hExplHolder = GUICreate("Explorer", $iWidth, $iHeight, Default, Default) Run('explorer.exe /n, "' & $sStartDir & '"') WinWait("[CLASS:CabinetWClass]") $hExplorer = WinGetHandle("[CLASS:CabinetWClass]") WinSetState($hExplorer, "", @SW_HIDE) WinMove($hExplorer, "", 0, 0, $iWidth, $iHeight) _WinAPI_SetParent($hExplorer, $hExplHolder) _WinAPI_SetWindowLong($hExplorer, $GWL_STYLE, -1064828928) ControlListView($hExplorer, "", "[CLASS:SysListView32; INSTANCE:1]", "ViewChange", "list") $hList = GUICtrlCreateListView ("File", $iWidth + 4, 4, 292, 200, 0x0003 + 0x0008 + 0x0004) GUICtrlSetState (-1, 8) WinSetState($hExplorer, "", @SW_SHOW) GUISetState(@SW_SHOW, $hExplHolder) While 1 $msg = GUIGetMsg() Switch $msg Case -3 Exit Case -13 GUICtrlCreateListViewItem (@GUI_DRAGFILE, $hList) EndSwitch WEnd Made it full screen so the person can see everything without that sidebar junk that was going on. Try this instead and change it to your code.
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