Radish Posted May 5, 2015 Share Posted May 5, 2015 (edited) Hi,I'm wondering how to do the following using AutoIt.Let's say I have an Explorer window open and I select multiple files and folders (so that they are highlighted in the Explorer window). Is there any way to get AutoIt to 'grab' all the full paths of all those highlighted folders and files (and only the highlighted ones because some the folders and files might not be 'selected' at all) in one go? Really so that I end up with a 'list' of the full paths of all the selected items. (I'm assuming that somewhere in Windows there is something that is actually storing the full paths to those folders and files as you select them.) Edited May 5, 2015 by Radish Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 5, 2015 Moderators Share Posted May 5, 2015 Radish,This works for me on Win7:; Read title of Explorer window $sTitle = ControlGetText("[CLASS:CabinetWClass]", "", "[CLASS:ToolbarWindow32;INSTANCE:2]") ; Extract path from title $sPath = StringRegExpReplace($sTitle, ".*(\w:\\.*)", "$1") ; Get selected items $sSelected = ControlListView("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32]", "GetSelected", 1) ; Convert to array $aSelected = StringSplit($sSelected, "|") For $i = 1 To $aSelected[0] ; Get text of items and prepend path $sItem = ControlListView("[CLASS:CabinetWClass]", "", "[CLASS:SysListView32]", "GetText", $aSelected[$i], 0) ; Display results ConsoleWrite($sPath & "\" & $sItem & @CRLF) NextAny use?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 Link to comment Share on other sites More sharing options...
Radish Posted May 5, 2015 Author Share Posted May 5, 2015 Thanks Melba. I've just tried this, compiled it and run the 'exe' but I can't tell if it's working as I can't see any output. Where does the output go?I had a quick look at ConsoleWrite in the AutoIt help file and it says something about "This does not write to a DOS console unless the script is compiled as a console application." I don't know how to complile in that way - is that something that I need to do?P.S. I too am running Win7. Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted May 5, 2015 Moderators Share Posted May 5, 2015 ConsoleWrite is only for uncompiled scripts.If you compile to executable, change the ConsoleWrite to a MsgBox for testing, or output to a file with FileWriteLine. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 5, 2015 Moderators Share Posted May 5, 2015 Radish,As JLogan3o13 has explained, ConsoleWrite is used mainly in uncompiled scripts run in SciTE where it displays the output in the lower pane of the editor window. As previously suggested, use a MsgBox or write to a file to see the output if you run the script compiled.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 Link to comment Share on other sites More sharing options...
LarsJ Posted May 6, 2015 Share Posted May 6, 2015 (edited) Melba23, Your code does definitely not work on Win 7 SP1 64 bit. On that OS Windows Explorer does not contain a SysListView32 control. Instead of it contains a DUIListView control which is a virtual listview. This can be verified with the UI Automation framework or Inspect.exe from Windows SDK. The control is not recognized by the "AutoIt Window Info" tool.To automate this DUIListView you can use Shell objects. One of the problems with Shell objects is, that only the objects which MicroSoft have implemented are available. But you can easily generate a list of selected items.Fortunately the Shell objects can also be created with ObjCreateInterface (native AutoIt function). When we ourselves create the objects, we can create all the objects we need.You can find an implementation of Shell objects created with ObjCreateInterface in Automating Windows Explorer. And you can find a collection of small examples here. This code works on all Windows versions. Edited May 6, 2015 by LarsJ Radish 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...
232showtime Posted May 6, 2015 Share Posted May 6, 2015 (edited) @Melba23i tried your script it works finewindows 7 professional sp1.one question,[CLASS:SysListView32] ;where did you get this? [CLASS:SysTreeView32; INSTANCE:1] ;this is what ive got from autoit window info Edited May 6, 2015 by 232showtime ill get to that... i still need to learn and understand a lot of codes Correct answer, learn to walk before you take on that marathon. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted May 6, 2015 Moderators Share Posted May 6, 2015 232showtime,You answered your own question: "got from autoit window info"LarsJ,Thanks for the additional information.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 Link to comment Share on other sites More sharing options...
Radish Posted May 17, 2015 Author Share Posted May 17, 2015 Hi,I tried Melba23's script, though I added a bit to it so that I could see output when the script is compiled. Basically the script doesn't work on my system, Windows 7 x64. It does correctly get the path to the location of the files and folders I've selected, but it doesn't get a list of the selected folders and files.For example if I select two folders and two files like this in the root directory of D:- Test Folder 1- Test Folder 2- Test File 1- Test File 2The only output Melba23's script produces is "D:\0" (The path D:\ is correct but the zero that follows is nothing like what I selected so, I assume, it's just an indication that the script detected that zero folders/files were selected and that it does that because that part of the script isn't working.)I've read the comments above and see that LarsJ says that the script won't t work on a Win7 x64 system. I looked at LarsJ comments and followed the links he provided and quickly tried out the scripts he provided - but they don't actually deal with my intial query, and to be honest I'm only a newbie and his examples are so complex I don't understand them.So could I repeat my original query and ask if someone knows of a way to get a list of selected folders and files in Explorer on a Win7 x64 system? (In language that a newbie can understand.) Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
mikell Posted May 17, 2015 Share Posted May 17, 2015 For this I personally use this *very* simple workaround (but not tested on w7 x64)HotKeySet("{ESC}", "Terminate") Hotkeyset("c", "_get") While 1 Sleep(10) Wend Func _get() Send("^c") Sleep(100) $list = ClipGet() ClipPut("") Msgbox(0,"", $list) EndFunc Func Terminate() Exit EndFunc Radish 1 Link to comment Share on other sites More sharing options...
Radish Posted May 17, 2015 Author Share Posted May 17, 2015 After several hours of tinkering with some parts of LarsJ's files contained in the zip file here I managed to get the output I needed for the script I'm working on. YES!Definitely don't understand most of what is in LarsJ's scripts though - very complicated.Thanks to all who responded and big thanks to LarsJ for providing the solution. Happy now! Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
Radish Posted May 17, 2015 Author Share Posted May 17, 2015 (edited) I say! Thanks for your solution, Mikell! After a quick test it seems to work fine, though I'd have to sort through the output once it goes to a text file. Or sort it properly before it's written to a text file. But I have a rough idea how to do that so that is within my capabilities.Many thanks.(That said I think I'll go with LarsJ's thing given that I worked for hours trying to puzzle out the bits I needed to puzzle out. Still stored your solution though, maybe it will be useful to me in the future. Thanks again.) Edited May 17, 2015 by Radish Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
Radish Posted May 17, 2015 Author Share Posted May 17, 2015 I just tested LarsJ's script by trying to highlight items on the Desktop. It doesn't work in that scenario. Ah! Of course not it's looking for content in an Explorer window.Then tested Mikell's solution on the Desktop. That does work for there. So I'll go with Mikell's solution for now as I need what I'm doing to also be able to work for items on the Desktop.Is it possible to get LarsJ's solution to work on the Desktop without it having to be opened in an Explorer window? Operating System: Windows 7 Pro. x64 SP1 Link to comment Share on other sites More sharing options...
KaFu Posted May 18, 2015 Share Posted May 18, 2015 Give this one a try. 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...
LarsJ Posted May 18, 2015 Share Posted May 18, 2015 Radish, Good to see that you got it to work. And good observation about the desktop. You are also right in the cause of the problem. I will certainly try if I can do something about it.I think the code by Melba23 in the post above will work for the desktop. The desktop seems to be a special implementation of Windows Explorer right pane. As far as I know the desktop is using the SysListView32 control on all Windows versions. Just replace CabinetWClass with Progman and the code by Melba23 should work. Of course there is no toolbar.It's not surprising that the solution by mikell is working. This code will probably work more or less on everything that can be treated as a selection. And it's probably also the fastest solution. Radish, if this solution works for you, you should stay with this.KaFu and Melba23, that's exactly the solution with Shell objects I was talking about. I thing this will work on all Windows versions. And also the desktop. Just use Progman for the class name of the desktop. 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...
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