AutoIt Forums: Embed MS Explorer pane in AutoIt GUI - AutoIt Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Embed MS Explorer pane in AutoIt GUI Can it be done?

#1 User is offline   Zachlr 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 68
  • Joined: 14-December 07

Posted 07 November 2009 - 01:58 AM

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

#2 User is online   Melba23 

  • Yes, me!
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 4,939
  • Joined: 01-August 08
  • Gender:Not Telling
  • Location:Where never lark or even eagle flew

Posted 07 November 2009 - 09:27 AM

Zachlr,

Lots of ideas here.

M23

#3 User is online   Mat 

  • Don't applaud. Just throw money
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,043
  • Joined: 26-February 09
  • Gender:Male
  • Location:Where the sun don't shine (England)

Posted 07 November 2009 - 11:57 AM

A few more improvements to that thread (I think)

[ autoIt ]    ( 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...

This post has been edited by Mat: 07 November 2009 - 11:58 AM


#4 User is offline   Zachlr 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 68
  • Joined: 14-December 07

Posted 07 November 2009 - 07:01 PM

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

#5 User is online   Mat 

  • Don't applaud. Just throw money
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,043
  • Joined: 26-February 09
  • Gender:Male
  • Location:Where the sun don't shine (England)

Posted 07 November 2009 - 07:42 PM

ControlListView should do what you want, I'll throw together an example for you soon. It is fairly self explanatory.

Mat

Edit:

[ autoIt ]    ( 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

This post has been edited by Mat: 07 November 2009 - 07:51 PM


#6 User is online   Melba23 

  • Yes, me!
  • Icon
  • Group: AutoIt MVPs(MVP)
  • Posts: 4,939
  • Joined: 01-August 08
  • Gender:Not Telling
  • Location:Where never lark or even eagle flew

Posted 07 November 2009 - 08:06 PM

Mat,

Thanks for that nice example.

M23

P.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! ;)

#7 User is online   Mat 

  • Don't applaud. Just throw money
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,043
  • Joined: 26-February 09
  • Gender:Male
  • Location:Where the sun don't shine (England)

Posted 08 November 2009 - 12:22 AM

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

#8 User is offline   Zachlr 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 68
  • Joined: 14-December 07

Posted 08 November 2009 - 12:51 AM

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.

#9 User is online   Mat 

  • Don't applaud. Just throw money
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,043
  • Joined: 26-February 09
  • Gender:Male
  • Location:Where the sun don't shine (England)

Posted 08 November 2009 - 12:01 PM

View PostZachlr, on 07 November 2009 - 11:51 PM, said:

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...
[ autoIt ]    ( 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 :(

This post has been edited by Mat: 08 November 2009 - 04:08 PM


#10 User is offline   Zachlr 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 68
  • Joined: 14-December 07

Posted 08 November 2009 - 10:56 PM

View PostMat, on 08 November 2009 - 03:01 AM, 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...
[ autoIt ]    ( 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

#11 User is online   Mat 

  • Don't applaud. Just throw money
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,043
  • Joined: 26-February 09
  • Gender:Male
  • Location:Where the sun don't shine (England)

Posted 08 November 2009 - 11:27 PM

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:
[ autoIt ]    ( 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

#12 User is offline   Zachlr 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 68
  • Joined: 14-December 07

Posted 09 November 2009 - 12:07 AM

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

#13 User is online   Mat 

  • Don't applaud. Just throw money
  • PipPipPipPipPipPipPip
  • Group: Full Members
  • Posts: 2,043
  • Joined: 26-February 09
  • Gender:Male
  • Location:Where the sun don't shine (England)

Posted 09 November 2009 - 09:51 AM

No... That code just showed the problem a lot more clearly. I only commented out a line :)

#14 User is offline   Zachlr 

  • Member
  • Pip
  • Group: Full Members
  • Posts: 68
  • Joined: 14-December 07

Posted 09 November 2009 - 04:59 PM

View PostMat, on 09 November 2009 - 12:51 AM, said:

No... That code just showed the problem a lot more clearly. I only commented out a line :)



Ah, my mistake.

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users