Embed MS Explorer pane in AutoIt GUI Can it be done?
#1
Posted 07 November 2009 - 01:58 AM
Thanks,
Zach
#3
Posted 07 November 2009 - 11:57 AM
#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...
This post has been edited by Mat: 07 November 2009 - 11:58 AM
#4
Posted 07 November 2009 - 07:01 PM
Thanks,
Zach
#5
Posted 07 November 2009 - 07:42 PM
Mat
Edit:
#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
This post has been edited by Mat: 07 November 2009 - 07:51 PM
#7
Posted 08 November 2009 - 12:22 AM
http://londondailyphoto.blogspot.com/200.../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
#9
Posted 08 November 2009 - 12:01 PM
Zachlr, on 07 November 2009 - 11:51 PM, said:
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...
#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 :(
This post has been edited by Mat: 08 November 2009 - 04:08 PM
#10
Posted 08 November 2009 - 10:56 PM
Mat, on 08 November 2009 - 03:01 AM, said:
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...
#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
#11
Posted 08 November 2009 - 11:27 PM
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:
#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
#12
Posted 09 November 2009 - 12:07 AM
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

Sign In
Register
Help
MultiQuote