mercadantelaura Posted March 18, 2014 Share Posted March 18, 2014 I need to create a TXT files with list of all files/folder full-PathFilename.ext that i have selected, but under win7 x64 command ControlListView don't run. How can i create my custom list ? Can you suggest me ho can implement that function ? Example --List.txt-- C:testfiletest.avi c:TestVideo.avi c:TestmyPersonalFolder thanks Link to comment Share on other sites More sharing options...
JohnOne Posted March 18, 2014 Share Posted March 18, 2014 Post the code that 'don't run'. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mercadantelaura Posted March 18, 2014 Author Share Posted March 18, 2014 Any code that use ControlListView don't run under win7 x64 only 32 bits Link to comment Share on other sites More sharing options...
JohnOne Posted March 18, 2014 Share Posted March 18, 2014 Then I suggest you report a bug. If none work, what is it you expect from this thread? AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mercadantelaura Posted March 18, 2014 Author Share Posted March 18, 2014 (edited) This is link to my old code-purpose solved by member LarsJ for an example of ControlList that that don't run beacuse listview on Win 7 is a virtual list view as LarsJ explained to me When i come back to home i will post also new script that i wrote to obtain list of selected item that under win7 x64 don't take effect Edited March 18, 2014 by mercadantelaura Link to comment Share on other sites More sharing options...
LarsJ Posted March 18, 2014 Share Posted March 18, 2014 mercadantelaura, I'll take a look. It can be done with the UI Automation framework.JohnOne, This has nothing to do with bugs, as the helpfile clearly states that ControlListView is for a ListView32 control, and the listview in Windows Explorer on Win 7 is not a ListView32 control. Is that you on the picture?Regards Lars. 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...
JohnOne Posted March 18, 2014 Share Posted March 18, 2014 Nah, that's the late Tony Benn AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
mercadantelaura Posted March 18, 2014 Author Share Posted March 18, 2014 Hi Mr. Lars. You is always disponible to help beginners :-) I'm prove to code to obtain same thing using "Clipboard" because UI Automation framework is too difficult to understand for me. Stupid question from a newbie but there is not possibility to improve ControlListView_Win7_version that include same all commands and options of old ControlListView of ListView32 that user can use again but have (internal function UI Automation framework) ? Link to comment Share on other sites More sharing options...
mercadantelaura Posted March 19, 2014 Author Share Posted March 19, 2014 Local $List Local $hw = WinGetHandle( "[CLASS:CabinetWClass]" ) If NOT $hw Then EXIT $FilesSelected = ControlListView($hw, "", "SysListView321", "GetSelected", 1 ) If $FilesSelected = "" Then EXIT Local $items = StringSplit($FilesSelected, "|") For $x = 1 to $items[0] $List = $List & ControlListView($hw, "", "SysListView321", "GetText", $items[$x]) & @CRLF Next MsgBox( 0, "", $List, 5 ) FileWrite ( "c:\MyList.txt", $List) This is my code under SysListView321 that under Win7 x64 don't take effect. Link to comment Share on other sites More sharing options...
LarsJ Posted March 19, 2014 Share Posted March 19, 2014 Try this:expandcollapse popup#include "CUIAutomation2.au3" Opt( "MustDeclareVars", 1 ) Global $oUIAutomation MainFunc() Func MainFunc() ; Get window handle for Windows Explorer Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]", "" ) ; Windows 7, 8 If Not $hWindow Then Return ; Create UI Automation object $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ; Condition to find listview Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition ) If Not $pCondition Then Return ; Find listview Local $pList, $oList $oWindow.FindFirst( $TreeScope_Descendants, $pCondition, $pList ) $oList = ObjCreateInterface( $pList, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oList ) Then Return ; Get all selected items GetAllSelectedItems( $oList ) EndFunc Func GetAllSelectedItems( $oList ) ; ItemContainer object ; A virtual listview must support the ItemContainer object Local $pItemContainer, $oItemContainer $oList.GetCurrentPattern( $UIA_ItemContainerPatternId, $pItemContainer ) $oItemContainer = ObjCreateInterface( $pItemContainer, $sIID_IUIAutomationItemContainerPattern, $dtagIUIAutomationItemContainerPattern ) If Not IsObj( $oItemContainer ) Then Return ; Find first item Local $pItem, $oItem ; The following command works for both real and virtual items $oItemContainer.FindItemByProperty( 0, $UIA_NamePropertyId, 0, $pItem ) $oItem = ObjCreateInterface( $pItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oItem ) Then Return ; Empty folder ; Is first item a virtual item? Local $pVirtualItem, $oVirtualItem $oItem.GetCurrentPattern( $UIA_VirtualizedItemPatternId, $pVirtualItem ) If $pVirtualItem Then ; First item is a virtual item, realize it $oVirtualItem = ObjCreateInterface( $pVirtualItem, $sIID_IUIAutomationVirtualizedItemPattern, $dtagIUIAutomationVirtualizedItemPattern ) $oVirtualItem.Realize() ; $oItem is now a real item EndIf Local $fSelected, $sName While $pItem ; Selected item? $oItem.GetCurrentPropertyValue( $UIA_SelectionItemIsSelectedPropertyId, $fSelected ) If $fSelected Then $oItem.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName ) ConsoleWrite( $sName & @CRLF ) EndIf ; Find next item $oItemContainer.FindItemByProperty( $pItem, $UIA_NamePropertyId, 0, $pItem ) $oItem = ObjCreateInterface( $pItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oItem ) Then ExitLoop ; No more items ; Virtual item? $oItem.GetCurrentPattern( $UIA_VirtualizedItemPatternId, $pVirtualItem ) If $pVirtualItem Then ; The item is a virtual item, realize it $oVirtualItem = ObjCreateInterface( $pVirtualItem, $sIID_IUIAutomationVirtualizedItemPattern, $dtagIUIAutomationVirtualizedItemPattern ) $oVirtualItem.Realize() ; $oItem is now a real item EndIf WEnd EndFuncYes, it is possible to create a new version of ControlListView for a virtual listview like the one in Windows Explorer on Windows 7 and 8. May be I'll do that. 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...
mercadantelaura Posted March 20, 2014 Author Share Posted March 20, 2014 (edited) Thanks Lars, you are very gentile but as i previously wrote i'm beginner and i don't know how try your code to obtain on my ROOT the "File.TXT" with all list of files/folders selected with their "Full-Path""Filename"."extension" Sorry but how is variable that contain list in order to create file to hard disk using FileWrite("c:\MyList.txt", $List) ControlListView for SysListView321 is more easy to use for beginner as me Edited March 20, 2014 by mercadantelaura Link to comment Share on other sites More sharing options...
mercadantelaura Posted March 20, 2014 Author Share Posted March 20, 2014 I have proved to show me using MsgBox the value of variable "$oUIAutomation" + "$sName" but error of variabled not declared is showed Unfortunately I don't know where list of selected items are stored using your code. :-( Link to comment Share on other sites More sharing options...
LarsJ Posted March 20, 2014 Share Posted March 20, 2014 The script above prints the names of the selected files to Scite console.I forgot the path. We can grep it from the toolbar. It's added in this script. And the file names are stored in an array. Then you just have to write the array to a file. expandcollapse popup#include "CUIAutomation2.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) Global $oUIAutomation MainFunc() Func MainFunc() ; Get window handle for Windows Explorer Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]", "" ) ; Windows 7, 8 If Not $hWindow Then Return ; Create UI Automation object $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ; Get UI Automation element from window handle Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return ; Condition to find toolbars Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ToolBarControlTypeId, $pCondition ) If Not $pCondition Then Return ; Find all toolbars Local $pUIElementArray, $oUIElementArray, $iElements $oWindow.FindAll( $TreeScope_Descendants, $pCondition, $pUIElementArray ) $oUIElementArray = ObjCreateInterface( $pUIElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray ) $oUIElementArray.Length( $iElements ) If Not $iElements Then Return ; Find toolbar with a name that contains ":\" Local $pUIElement, $oUIElement, $sName, $sPath, $p For $i = 0 To $iElements - 1 $oUIElementArray.GetElement( $i, $pUIElement ) $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) $oUIElement.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName ) $p = StringInStr( $sName, ":\" ) If $p > 0 Then $sPath = StringRight( $sName, StringLen( $sName ) - $p + 2 ) ConsoleWrite( $sPath & @CRLF ) ExitLoop EndIf Next ; Condition to find listview $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition ) If Not $pCondition Then Return ; Find listview Local $pList, $oList $oWindow.FindFirst( $TreeScope_Descendants, $pCondition, $pList ) $oList = ObjCreateInterface( $pList, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oList ) Then Return ; Get all selected items GetAllSelectedItems( $oList, $sPath ) EndFunc Func GetAllSelectedItems( $oList, $sPath ) Local $aList[10000], $iList = 0 ; ItemContainer object ; A virtual listview must support the ItemContainer object Local $pItemContainer, $oItemContainer $oList.GetCurrentPattern( $UIA_ItemContainerPatternId, $pItemContainer ) $oItemContainer = ObjCreateInterface( $pItemContainer, $sIID_IUIAutomationItemContainerPattern, $dtagIUIAutomationItemContainerPattern ) If Not IsObj( $oItemContainer ) Then Return ; Find first item Local $pItem, $oItem ; The following command works for both real and virtual items $oItemContainer.FindItemByProperty( 0, $UIA_NamePropertyId, 0, $pItem ) $oItem = ObjCreateInterface( $pItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oItem ) Then Return ; Empty folder ; Is first item a virtual item? Local $pVirtualItem, $oVirtualItem $oItem.GetCurrentPattern( $UIA_VirtualizedItemPatternId, $pVirtualItem ) If $pVirtualItem Then ; First item is a virtual item, realize it $oVirtualItem = ObjCreateInterface( $pVirtualItem, $sIID_IUIAutomationVirtualizedItemPattern, $dtagIUIAutomationVirtualizedItemPattern ) $oVirtualItem.Realize() ; $oItem is now a real item EndIf Local $fSelected, $sName While $pItem ; Selected item? $oItem.GetCurrentPropertyValue( $UIA_SelectionItemIsSelectedPropertyId, $fSelected ) If $fSelected Then $oItem.GetCurrentPropertyValue( $UIA_NamePropertyId, $sName ) $sName = $sPath & "\" & $sName ConsoleWrite( $sName & @CRLF ) $aList[$iList] = $sName $iList += 1 EndIf ; Find next item $oItemContainer.FindItemByProperty( $pItem, $UIA_NamePropertyId, 0, $pItem ) $oItem = ObjCreateInterface( $pItem, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oItem ) Then ExitLoop ; No more items ; Virtual item? $oItem.GetCurrentPattern( $UIA_VirtualizedItemPatternId, $pVirtualItem ) If $pVirtualItem Then ; The item is a virtual item, realize it $oVirtualItem = ObjCreateInterface( $pVirtualItem, $sIID_IUIAutomationVirtualizedItemPattern, $dtagIUIAutomationVirtualizedItemPattern ) $oVirtualItem.Realize() ; $oItem is now a real item EndIf WEnd ReDim $aList[$iList] _ArrayDisplay( $aList, "Selected items" ) EndFunc 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...
mercadantelaura Posted March 21, 2014 Author Share Posted March 21, 2014 OK Thanks, now it runs but there are some problems. The file list.TXT created is the input of an other freeware program that load this file list, but to run correctly it needs : "DriveLetterPathFileName.Extension" ...example... "c:MyFolderABCDEFProgramMyFile01.mp3" The list of files created have extension at the end of filename only if file is not knowed from Widnows. My explorer as default Hide extensions of files recognized and in this case script don't create correctly list because extension is not reported at the end of file. In addiction i have folders with more than 5.000 files and script glide the list files on screen when i run it and it takes lots time to generate file.TXT. There isn't other method to create file list of selected ? -- I have wrote this code but using it, i have 2 problems: --- (1) I am obliged to use Singleton because without it, lots session of application "MyProg" start (each session of every item selected), Why ??? (2) If i select also only one folder that contain 200-300 GB of Data The program not load all data (I think that is a BUG of freeware program ) #NoTrayIcon #include <Misc.au3> _Singleton("MyList", 0) ; Without Singleton at the end script start N° sessions equal the number of selected files Local $hw = WinGetHandle( "[CLASS:CabinetWClass]" ) If NOT $hw Then EXIT While 1 ; Generate a valid Random FileName of List $File = @TempDIR & "\List-" & INT ( Random ( 10^10 ) ) & ".TXT" If NOT FileExists( $File ) Then ExitLoop WEND ClipPut ( "" ) ; Clean ClipBoard Memory Send("^c") ; Copy to clipboard all FULL PATH + FILENAME + EXTENSIONS of selected items Sleep(150) Local $ItemSelected = ClipGet() ; Store clipboard selected items into variable FileWriteLine($File, $ItemSelected) ; Write on file "$CmdLine[1]" the list generated Sleep(150) ; wait to be finished writing Run("MyProg" & $File) ; start MyProg that load Text List of all files selected Link to comment Share on other sites More sharing options...
LarsJ Posted March 23, 2014 Share Posted March 23, 2014 There are other ways to create the list. Try this:Opt( "MustDeclareVars", 1 ) MainFunc() Func MainFunc() ; Windows Explorer on Windows XP, Vista, 7, 8 Local $hWindow = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hWindow Then Return ; Shell object Local $oShell = ObjCreate( "Shell.Application" ) ; Find window For $oWindow In $oShell.Windows() If $oWindow.HWND() = $hWindow Then ExitLoop Next ; Selected items For $oFolderItem In $oWindow.Document().SelectedItems() ConsoleWrite( $oFolderItem.Path() & @CRLF ) Next EndFunc 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...
mercadantelaura Posted March 25, 2014 Author Share Posted March 25, 2014 (edited) Thank you very much LarsJ for your help. I have replaced ConsoleWrite( $oFolderItem.Path() & @CRLF ) with FileWriteLine("C:List.txt", $oFolderItem.Path() & @CRLF) and all run. I found a limit: If i have files or folders selected on desktop the script don't take effect In addiction i have always same question: Where is allocated all list of files in order to write variable using only one pass for all selection data when FOR-NEXT is finished and not write on HD during cycle FOR-NEXT?? I have proved: $data = ConsoleRead() but is always empty Now your code is more rapid that previously but it takes more than 10 seconds to load list of 5.000 mp3 (small part of all my list), compared using function "ClipBoard" that emploied 2 seconds. I have upgrade my alternative code to run also on desktop using your past code from other topic that i have used for other purpose. Unfortunately i have not sufficient experience to how know directly the number of files selected and for my limit i have used command "StringInStr" to extrapolate number of selected from variable $sStatus into function nSelect() expandcollapse popup; My Script #NoTrayIcon #include <CUIAutomation2.au3> #include <misc.au3> _Singleton("MyList", 0) $Prog = "MyProg" If NOT FileExists(@scriptDIR & "\" & $Prog & ".exe") then Exit Local $Desktop = "SysListView321" ; Desktop Control of Win7 Local $hWindow = WinGetHandle( "[active]" ) Local $ItemSelected = "" If ControlGetFocus($hWindow) = $Desktop Then $nSelect = ControlListView ( $hWindow, "", $Desktop, "GetSelectedCount" ) Else Local $nSelect = nSelect() Endif ClipPut ( "" ) Send("^c") ; Copy to clipboard all FULL PATH + FILENAME + EXTENSIONS of selected items Select Case $nSelect = "0" Run($Prog) Case $nSelect = 1 While $ItemSelected = "" Sleep(10) Local $ItemSelected = ClipGet() WEND Run($Prog & " COPY " & '"' & $ItemSelected & '"') Case $nSelect > 1 While 1 $File = @TempDIR & "\List-" & INT ( Random ( 10^10 ) ) If NOT FileExists( $File ) Then ExitLoop WEND While $ItemSelected = "" Sleep(10) Local $ItemSelected = ClipGet() WEND FileWriteLine($File, $ItemSelected) Run($prog & " COPY *" & $File) EndSelect Do Sleep(10) Until WinActive($Prog) Send("{TAB}{ENTER}") Func nSelect() Local $oUIAutomation $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return Local $pWindow, $oWindow $oUIAutomation.ElementFromHandle( $hWindow, $pWindow ) $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oWindow ) Then Return Local $pCondition $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_ListControlTypeId, $pCondition ) If Not $pCondition Then Return Local $pUIList, $oUIList $oWindow.FindFirst( $TreeScope_Descendants, $pCondition, $pUIList ) $oUIList = ObjCreateInterface( $pUIList, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oUIList ) Then Return Local $sStatus $oUIList.GetCurrentPropertyValue( $UIA_ItemStatusPropertyId, $sStatus ) If StringInStr ( $sStatus, "sele") > 0 Then ; "If there is 'word: sele' in $status message extrapolate the number of item selected frim string Local $FileSelect = StringSplit ( StringRight($sStatus, StringLen ($sStatus) - (StringInStr ($sStatus, ",") + 1)), " " ) Return $FileSelect[1] Else Return 0 Endif EndFunc Edited March 25, 2014 by mercadantelaura 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