Popular Post LarsJ Posted July 20, 2014 Popular Post Share Posted July 20, 2014 (edited) In the last versions of Windows, it has been difficult to automate Windows Explorer. But there are many examples of code like this to extract the selected items: ; Windows Explorer on XP, Vista, 7, 8 $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then Exit ; Shell object $oShell = ObjCreate( "Shell.Application" ) ; Find window For $oWindow In $oShell.Windows() If $oWindow.HWND() = $hExplorer Then ExitLoop Next ; Selected items For $oItem In $oWindow.Document.SelectedItems() ConsoleWrite( $oItem.Path() & @CRLF ) Next It's possible to create these objects with ObjCreateInterface. More precisely, create an IShellBrowser interface for the top level browser of an open Windows Explorer. Plan and code This is the plan: Create an IShellWindows interface to get a list of shell windows Get an IWebBrowserApp object for each window. This is done in two steps: Get an IDispatch object for the window Get the IWebBrowserApp interface Identify the proper shell window with get_HWND of IWebBrowserApp Get an IServiceProvider interface with QueryInterface of IWebBrowserApp Get the IShellBrowser interface with QueryService of IServiceProvider This is the code: expandcollapse popupFunc GetIShellBrowser( $hExplorer ) ; IShellWindows interface Local $pIShellWindows, $oIShellWindows CoCreateInstance( $tCLSID_ShellWindows, $NULL, $CLSCTX_ALL, $tRIID_IShellWindows, $pIShellWindows ) $oIShellWindows = ObjCreateInterface( $pIShellWindows, $sIID_IShellWindows, $dtag_IShellWindows ) ; Number of shell windows Local $iWindows $oIShellWindows.get_Count( $iWindows ) ; Get an IWebBrowserApp object for each window ; This is done in two steps: ; 1. Get an IDispatch object for the window ; 2. Get the IWebBrowserApp interface ; Check if it's the right window Local $pIDispatch, $oIDispatch Local $pIWebBrowserApp, $oIWebBrowserApp, $hWnd For $i = 0 To $iWindows - 1 $oIShellWindows.Item( $i, $pIDispatch ) If $pIDispatch Then $oIDispatch = ObjCreateInterface( $pIDispatch, $sIID_IDispatch, $dtag_IDispatch ) $oIDispatch.QueryInterface( $tRIID_IWebBrowserApp, $pIWebBrowserApp ) If $pIWebBrowserApp Then $oIWebBrowserApp = ObjCreateInterface( $pIWebBrowserApp, $sIID_IWebBrowserApp, $dtag_IWebBrowserApp ) $oIWebBrowserApp.get_HWND( $hWnd ) If $hWnd = $hExplorer Then ExitLoop EndIf EndIf Next ; IServiceProvider interface Local $pIServiceProvider, $oIServiceProvider $oIWebBrowserApp.QueryInterface( $tRIID_IServiceProvider, $pIServiceProvider ) $oIServiceProvider = ObjCreateInterface( $pIServiceProvider, $sIID_IServiceProvider, $dtag_IServiceProvider ) ; IShellBrowser interface Local $pIShellBrowser $oIServiceProvider.QueryService( $tRIID_STopLevelBrowser, $tRIID_IShellBrowser, $pIShellBrowser ) $oIShellBrowser = ObjCreateInterface( $pIShellBrowser, $sIID_IShellBrowser, $dtag_IShellBrowser ) EndFunc Now it's easy to create the shell interfaces. The main interfaces are: expandcollapse popupFunc GetShellInterfaces() Local $pIFolderView, $pIFolderView2, $pIPersistFolder2, $pIShellFolder, $pPidlFolder, $pPidlRel, $i = 0 ; IShellView interface $oIShellBrowser.QueryActiveShellView( $pIShellView ) $oIShellView = ObjCreateInterface( $pIShellView, $sIID_IShellView, $dtag_IShellView ) ; IFolderView interface $oIShellView.QueryInterface( $tRIID_IFolderView, $pIFolderView ) $oIFolderView = ObjCreateInterface( $pIFolderView, $sIID_IFolderView, $dtag_IFolderView ) If @OSVersion <> "WIN_XP" Then ; IFolderView2 interface (Vista and later) $oIShellView.QueryInterface( $tRIID_IFolderView2, $pIFolderView2 ) $oIFolderView2 = ObjCreateInterface( $pIFolderView2, $sIID_IFolderView2, $dtag_IFolderView2 ) EndIf ; IPersistFolder2 interface $oIFolderView.GetFolder( $tRIID_IPersistFolder2, $pIPersistFolder2 ) $oIPersistFolder2 = ObjCreateInterface( $pIPersistFolder2, $sIID_IPersistFolder2, $dtag_IPersistFolder2 ) $oIPersistFolder2.GetCurFolder( $pPidlFolder ) ; IShellFolder interface If ILIsEqual( $pPidlFolder, $pPidlAbsDesktop ) Then SHGetDesktopFolder( $pIShellFolder ) Else Local $pIParentFolder, $oIParentFolder, $pPidlRel SHBindToParent( $pPidlFolder, DllStructGetPtr( $tRIID_IShellFolder ), $pIParentFolder, $pPidlRel ) $oIParentFolder = ObjCreateInterface( $pIParentFolder, $sIID_IShellFolder, $dtag_IShellFolder ) $oIParentFolder.BindToObject( $pPidlRel, $NULL, $tRIID_IShellFolder, $pIShellFolder ) EndIf $oIShellFolder = ObjCreateInterface( $pIShellFolder, $sIID_IShellFolder, $dtag_IShellFolder ) ; Free memory used by $pPidlFolder _WinAPI_CoTaskMemFree( $pPidlFolder ) ; Wait for Explorer to refresh $pPidlRel = GetFocusedItem() While Not $pPidlRel And $i < 10 Sleep( 25 ) $pPidlRel = GetFocusedItem() $i += 1 WEnd ; Free memory used by $pPidlRel If $pPidlRel Then _ _WinAPI_CoTaskMemFree( $pPidlRel ) EndFunc Features The methods of the interfaces supports the following features: You can handle items in Windows Explorer: Get current folder, get all items, get/set selected items and get/set focused item. A selected file is opened by executing the InvokeCommand for the default item in the context menu. You can browse to a specific folder or a parent/child folder. You can set icon view mode. Functions AutomatingWindowsExplorer.au3 contains the two functions above. And it contains a number of functions to implement the features: GetCurrentFolder SetCurrentFolder CountItems GetItems GetFiles GetFolders GetPidls GetFocusedItem SetFocusedItem SetSelectedItem GetIconView SetIconView When the interfaces are created, the functions can be implemented with a few lines of code. This is the code for GetCurrentFolder and SetCurrentFolder: Func GetCurrentFolder() Local $pPidlAbs $oIPersistFolder2.GetCurFolder( $pPidlAbs ) Return $pPidlAbs EndFunc ; After this command $oIShellBrowser is the only valid interface object. To ; be able to use the other interfaces you must execute GetShellInterfaces(). Func SetCurrentFolder( $pPidl, $fFlag ) $oIShellBrowser.BrowseObject( $pPidl, BitOR( $SBSP_DEFBROWSER, $fFlag ) ) EndFunc For examples search the functions in Example.au3 and Example*.au3. Depending on parameters most functions can return PIDLs. Some functions return only PIDLs. In these cases you must free memory (_WinAPI_CoTaskMemFree) used by the PIDLs, when you have finished using the PIDLs. There are many more methods that are not implemented in these functions, and there are available interfaces that have not been created. Example Example.au3 demonstrates the features. Example folder contains scripts with functions used in the example. It's important that there is consistency between the interfaces, and the current folder in Windows Explorer. If the GUI loses and gets focus, it's checked if the current folder is changed. In that case the interfaces are updated to match the new folder. This is a picture of the GUI: Items and selected items are shown with _ArrayDisplay. The number of rows in the listview to the right is limited to 100. The listview can only be used for the buttons in the lower right group. The buttons in the lower left group are disabled, if there are more than 100 items in the folder. There is also a listview on the second tab item. It's limited to 100 rows, and can only be used for the Child folder button. You can also double click a child folder in the listview, to browse to this folder. Control Panel The example does not work for the Control Panel. The reason is that the child windows which are created for the Control Panel, are different from the child windows which are created for other folders. You can verify that with the UI Automation framework. Zipfile Example - include files used in example Includes - include files used for Automating Windows Explorer Example.au3 - Example For AutoIt 3.3.10 and later. Testet on Windows XP 32 bit and Windows 7 32/64 bit. Automating Windows Explorer.7z Examples in posts belowPost 7 is a collection of small examples.Post 15 shows how to automate a search with UI Automation code.Post 31 shows how to execute a function on a double-click in empty space of the right pane window (the listview). The code contains UI Automation code.Post 38 is UI Automation code to make a selected item visible by scrolling the listview up or down.  Edited September 28, 2017 by LarsJ New image link, list of examples KaFu, Vincor, KLM and 8 others 9 2 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...
johnmcloud Posted July 20, 2014 Share Posted July 20, 2014 Well done Link to comment Share on other sites More sharing options...
junkew Posted July 20, 2014 Share Posted July 20, 2014 Nice FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
AutID Posted July 20, 2014 Share Posted July 20, 2014 A must have udf. Great job. https://iblockify.wordpress.com/ Link to comment Share on other sites More sharing options...
Inververs Posted August 12, 2014 Share Posted August 12, 2014 (edited) ingeniously! How do you describe the "interface_description". Do you have a parser h/idl files? or do everything manually? Edited August 12, 2014 by Inververs Link to comment Share on other sites More sharing options...
LarsJ Posted August 13, 2014 Author Share Posted August 13, 2014 (edited) I do everything manually, based on C/C++ header files. But because I've added more examples dealing with Shell Interfaces, I've probably only created two new interfaces for this example: IWebBrowser and IWebBrowserApp. The rest of the interfaces are just copied. You find the interface descriptions in IncludesShellInterfaces.au3.IWebBrowser (needed because IWebBrowserApp inherits from IWebBrowser) and IWebBrowserApp together comprise almost 50 methods. But because I only use one method out of these 50, namely get_HWND in IWebBrowserApp, I have only added parameters for this method. The most time consuming task is to add parameters. All in all, I probably only spend five minutes to add the two interface descriptions.So it's not that difficult to create interface descriptions, as it might first appear.Thanks to all for comments and likes. Edited August 13, 2014 by LarsJ davidacrozier 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...
Popular Post LarsJ Posted February 24, 2015 Author Popular Post Share Posted February 24, 2015 (edited) Here is a collection of small examples. Windows Explorer should be open before you run the examples.If you create shortcuts for the scripts, and copy the shortcuts to the desktop, you can run the examples and use Windows Explorer at the same time. For some of the examples you can select files or folders before you run the example.1) GetCurrentFolder.au3#include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get current folder Local $pFolder = GetCurrentFolder(), $sFolder SHGetPathFromIDList( $pFolder, $sFolder ) MsgBox( 0, "Folder", $sFolder ) ; Free memory _WinAPI_CoTaskMemFree( $pFolder ) EndFunc2) SetCurrentFolder.au3#include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Set current folder to desktop Local $pDesktop = _WinAPI_ShellGetSpecialFolderLocation( $CSIDL_DESKTOP ) SetCurrentFolder( $pDesktop, $SBSP_ABSOLUTE ) ; Free memory _WinAPI_CoTaskMemFree( $pDesktop ) EndFunc3) CountItems.au3#include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Count files and folders MsgBox( 0, "Count files and folders", CountItems() ) ; Count selected files and folders MsgBox( 0, "Count selected files and folders", CountItems( True ) ) EndFunc4) GetFiles.au3#include "Includes\AutomatingWindowsExplorer.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get all files with full path ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aFiles = GetFiles( False, True ) _ArrayDisplay( $aFiles, "All files" ) ; Get selected files with full path ;GetFiles( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) $aFiles = GetFiles( True, True ) _ArrayDisplay( $aFiles, "Selected files" ) EndFunc5) GetFolders.au3#include "Includes\AutomatingWindowsExplorer.au3" #include <Array.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get all folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) Local $aFolders = GetFolders() _ArrayDisplay( $aFolders, "All folders" ) ; Get selected folders ;GetFolders( $fSelected = False, $fFullPath = False, $fPidl = False, $iMax = 0 ) $aFolders = GetFolders( True ) _ArrayDisplay( $aFolders, "Selected folders" ) EndFunc6) SetSelectedItem.au3#include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Set second item selected SetSelectedItem( 1 ) EndFunc7) GetSetIconView.au3expandcollapse popup#include "Includes\AutomatingWindowsExplorer.au3" Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; Get other interfaces GetShellInterfaces() ; Get current icon view Local $view = GetIconView() Local $iView, $iSize If IsArray( $view ) Then ; OS > XP $iView = $view[0] ; Icon view $iSize = $view[1] ; Icon size If $iView <> $FVM_DETAILS Then ; Not details view SetIconView( $FVM_DETAILS, 16 ) ; Set details view ElseIf $iView <> $FVM_ICON Then ; Not icon view SetIconView( $FVM_ICON, 48 ) ; Set icon view EndIf Sleep( 3000 ) ; Wait 3 seconds SetIconView( $iView, $iSize ) ; Restore old view Else ; OS = XP $iView = $view If $iView <> $FVM_DETAILS Then ; Not details view SetIconView( $FVM_DETAILS ) ; Set details view ElseIf $iView <> $FVM_ICON Then ; Not icon view SetIconView( $FVM_ICON ) ; Set icon view EndIf Sleep( 3000 ) ; Wait 3 seconds SetIconView( $iView ) ; Restore old view EndIf EndFuncZipfileThe zip contains examples and necessary include files.Examples.7z Edited February 24, 2015 by LarsJ KLM, Vincor, Netol and 6 others 8 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...
mLipok Posted April 4, 2015 Share Posted April 4, 2015 AwesomeThanks for sharingmLipok kcvinu 1 Signature beginning:* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *  My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"  , be   and    \\//_. Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
KLM Posted April 5, 2015 Share Posted April 5, 2015 Thanks K L M ------------------ Real Fakenamovich ------------------ K L M ------------------ Real Fakenamovich ------------------ Link to comment Share on other sites More sharing options...
maniootek Posted October 3, 2016 Share Posted October 3, 2016 (edited) Any chance to perform a search using your UDF? Edited October 3, 2016 by maniootek Link to comment Share on other sites More sharing options...
LarsJ Posted October 5, 2016 Author Share Posted October 5, 2016 I think it's fairly easy. But you'll probably have to wait for the weekend. 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...
junkew Posted October 6, 2016 Share Posted October 6, 2016 should be possible with https://msdn.microsoft.com/en-us/library/bb775176(vs.85).aspx and linking that to the explorer. Could not find a clear example FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
kcvinu Posted October 6, 2016 Share Posted October 6, 2016 (edited) @LarsJ Thanks for those examples. I think that should be placed in wiki.  Edited October 6, 2016 by kcvinu Spoiler My Contributions Glance GUI Library - A gui library based on Windows api functions. Written in Nim programming language. UDF Link Viewer  --- A tool to visit the links of some most important UDFs  Includer_2  ----- A tool to type the #include statement automatically  Digits To Date ----- date from 3 integer values PrintList ----- prints arrays into console for testing.  Alert ------ An alternative for MsgBox  MousePosition ------- A simple tooltip display of mouse position GRM Helper -------- A littile tool to help writing code with GUIRegisterMsg function Access_UDF  -------- An UDF for working with access database files. (.*accdb only)  Link to comment Share on other sites More sharing options...
LarsJ Posted October 7, 2016 Author Share Posted October 7, 2016 junkew, Interesting interface. I've never used it. I hope to do it with a few more simple steps: Set the start folder for the search (example 2 above) Fill out the search field in the same way as this Wait some time while the search is performed until the count of items (example 3) is stable Extract the files and folders which is the result of the search (example 4 and 5)  kcvinu, I'll think about it. At least I can add the example to the list of UDFs. kcvinu 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...
LarsJ Posted October 9, 2016 Author Share Posted October 9, 2016 (edited) The example sets the search folder to C:\Windows\System32 and searches for files and folders with "com" in the name. Windows Explorer must be open before you run the example.  8) PerformSearch.au3 expandcollapse popup#include "Includes\AutomatingWindowsExplorer.au3" #include "Includes\CUIAutomation2.au3" #include <WinAPIShellEx.au3> #include <Array.au3> Opt( "MustDeclareVars", 1 ) Example() Func Example() ; Windows Explorer on XP, Vista, 7, 8 Local $hExplorer = WinGetHandle( "[REGEXPCLASS:^(Cabinet|Explore)WClass$]" ) If Not $hExplorer Then MsgBox( 0, "Automating Windows Explorer", "Could not find Windows Explorer. Terminating." ) Return EndIf ; Get an IShellBrowser interface GetIShellBrowser( $hExplorer ) If Not IsObj( $oIShellBrowser ) Then MsgBox( 0, "Automating Windows Explorer", "Could not get an IShellBrowser interface. Terminating." ) Return EndIf ; --- Set search folder --- ; Get interfaces GetShellInterfaces() ; Set current folder, C:\Windows\System32 Local $pFolder = _WinAPI_ShellILCreateFromPath( "C:\Windows\System32" ) SetCurrentFolder( $pFolder, $SBSP_ABSOLUTE ) ; Free memory _WinAPI_CoTaskMemFree( $pFolder ) ; --- Start a search --- ; Automation object Local $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation ) If Not IsObj( $oUIAutomation ) Then Return ConsoleWrite( "$oUIAutomation ERR" & @CRLF ) ConsoleWrite( "$oUIAutomation OK" & @CRLF ) ; Explorer object Local $pExplorer, $oExplorer $oUIAutomation.ElementFromHandle( $hExplorer, $pExplorer ) $oExplorer = ObjCreateInterface( $pExplorer, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oExplorer ) Then Return ConsoleWrite( "$oExplorer ERR" & @CRLF ) ConsoleWrite( "$oExplorer OK" & @CRLF ) ; Find condition Local $pCondition ; Use Inspect.exe (Inspect Objects) to verify that the search box is an Edit control $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $UIA_EditControlTypeId, $pCondition ) If Not $pCondition Then Return ConsoleWrite( "$pCondition ERR" & @CRLF ) ConsoleWrite( "$pCondition OK" & @CRLF ) ; Find Edit Local $pEdit, $oEdit ; This is the first Edit control $oExplorer.FindFirst( $TreeScope_Descendants, $pCondition, $pEdit ) $oEdit = ObjCreateInterface( $pEdit, $sIID_IUIAutomationElement, $dtagIUIAutomationElement ) If Not IsObj( $oEdit ) Then Exit ConsoleWrite( "$oEdit ERR" & @CRLF ) ConsoleWrite( "$oEdit OK" & @CRLF ) ; Get Edit Value object Local $pEditValue, $oEditValue $oEdit.GetCurrentPattern( $UIA_ValuePatternId, $pEditValue ) $oEditValue = ObjCreateInterface( $pEditValue, $sIID_IUIAutomationValuePattern, $dtagIUIAutomationValuePattern ) If Not IsObj( $oEditValue ) Then Exit ConsoleWrite( "$oEditValue ERR" & @CRLF ) ConsoleWrite( "$oEditValue OK" & @CRLF ) ; Set search text, com $oEditValue.SetValue( "com" ) ; Wait a second Sleep( 1000 ) ; --- Get search results --- ; Get interfaces (for Search Results right pane window) GetShellInterfaces() ; Wait while the search is performed Local $iCount = 0, $iCountPrev = -1 While $iCount <> $iCountPrev Sleep( 1000 ) ; Wait a second in each loop $iCountPrev = $iCount $iCount = CountItems() WEnd ; Get search results Local $aItems = GetItems( False, True ) ; $fSelected, $fFullPath _ArrayDisplay( $aItems, "Search Results" ) EndFunc  The zip contains the example and all include files: Example8.7z  I've tested the new example on Windows 10 and 7. It does not work on Windows XP. I've tested the old examples in post 7 on Windows 10. They are all working. Edited October 9, 2016 by LarsJ KaFu and mLipok 1 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...
junkew Posted October 9, 2016 Share Posted October 9, 2016 (edited) navigate to: search-ms:query=automation& Studied a little on this microsoft search and its interface but seems overwhelmingly complex but apparantly above in a navigate to command of ie or explorer seems to to the trick without going to the searchbox and sendkeys. https://msdn.microsoft.com/en-us/library/windows/desktop/bb266520(v=vs.85).aspx Edited October 9, 2016 by junkew FAQ 31 How to click some elements, FAQ 40 Test automation with AutoIt, Multithreading CLR .NET Powershell CMDLets Link to comment Share on other sites More sharing options...
mLipok Posted October 9, 2016 Share Posted October 9, 2016 Please consider to add:  WinActivate($hExplorer) in some of your examples.  Can I use WinList and then several times use GetIShellBrowser( $hExplorer ) in a For ... Next loop  ? I want to find/use Explorer window with specyfic URL. How to set order by ModyficationDate ( Asceding/Desceding ) ? How to show / hide some columns ie. Tags, Authors, Creation date/time ?  Signature beginning:* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *  My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"  , be   and    \\//_. Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
LarsJ Posted October 11, 2016 Author Share Posted October 11, 2016 junkew, With this technique you can only search through indexed folders. Except for the default folders I've no indexed folders on my PC. I'm not using this indexing functionality. Because Windows Explorer is Microsoft code the SetValue method of the ValuePattern object is working. I'm not using any Send-commands as you can see in the code. mLipok, 1) Because you run the examples in SciTE (which I don't) and then SciTE is active instead of Windows Explorer? 2) See first code box in first post to get a list of all Explorer windows. 3,4) I'll see what I can do. 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...
mLipok Posted October 11, 2016 Share Posted October 11, 2016 Thanks Signature beginning:* Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules ** ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Code * for other useful stuff click the following button: Spoiler Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind. My contribution (my own projects): * Debenu Quick PDF Library - UDF * Debenu PDF Viewer SDK - UDF * Acrobat Reader - ActiveX Viewer * UDF for PDFCreator v1.x.x * XZip - UDF * AppCompatFlags UDF * CrowdinAPI UDF * _WinMergeCompare2Files() * _JavaExceptionAdd() * _IsBeta() * Writing DPI Awareness App - workaround * _AutoIt_RequiredVersion() * Chilkatsoft.au3 UDF * TeamViewer.au3 UDF * JavaManagement UDF * VIES over SOAP * WinSCP UDF * GHAPI UDF - modest begining - comunication with GitHub REST API * ErrorLog.au3 UDF - A logging Library * Include Dependency Tree (Tool for analyzing script relations) * Show_Macro_Values.au3 *  My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 UDF * ADO.au3 UDF * SMTP Mailer UDF * Dual Monitor resolution detection * * 2GUI on Dual Monitor System * _SciLexer.au3 UDF * SciTE - Lexer for console pane * Useful links: * Forum Rules * Forum etiquette * Forum Information and FAQs * How to post code on the forum * AutoIt Online Documentation * AutoIt Online Beta Documentation * SciTE4AutoIt3 getting started * Convert text blocks to AutoIt code * Games made in Autoit * Programming related sites * Polish AutoIt Tutorial * DllCall Code Generator * Wiki: * Expand your knowledge - AutoIt Wiki * Collection of User Defined Functions * How to use HelpFile * Good coding practices in AutoIt * OpenOffice/LibreOffice/XLS Related: WriterDemo.au3 * XLS/MDB from scratch with ADOX IE Related:  * How to use IE.au3  UDF with  AutoIt v3.3.14.x * Why isn't Autoit able to click a Javascript Dialog? * Clicking javascript button with no ID * IE document >> save as MHT file * IETab Switcher (by LarsJ ) * HTML Entities * _IEquerySelectorAll() (by uncommon) * IE in TaskScheduler * IE Embedded Control Versioning (use IE9+ and HTML5 in a GUI) * PDF Related: * How to get reference to PDF object embeded in IE * IE on Windows 11 * I encourage you to read: * Global Vars * Best Coding Practices * Please explain code used in Help file for several File functions * OOP-like approach in AutoIt * UDF-Spec Questions * EXAMPLE: How To Catch ConsoleWrite() output to a file or to CMD *I also encourage you to check awesome @trancexx code: * Create COM objects from modules without any demand on user to register anything. * Another COM object registering stuff * OnHungApp handler * Avoid "AutoIt Error" message box in unknown errors  * HTML editor * winhttp.au3 related : * https://www.autoitscript.com/forum/topic/206771-winhttpau3-download-problem-youre-speaking-plain-http-to-an-ssl-enabled-server-port/ "Homo sum; humani nil a me alienum puto" - Publius Terentius Afer"Program are meant to be read by humans and only incidentally for computers and execute" - Donald Knuth, "The Art of Computer Programming"  , be   and    \\//_. Anticipating Errors :  "Any program that accepts data from a user must include code to validate that data before sending it to the data store. You cannot rely on the data store, ...., or even your programming language to notify you of problems. You must check every byte entered by your users, making sure that data is the correct type for its field and that required fields are not empty." Signature last update: 2023-04-24 Link to comment Share on other sites More sharing options...
sceatch Posted November 25, 2016 Share Posted November 25, 2016 Hi, can someone please make a script for go back in explorer window on one level up, if i double click on it's empty area? Like in QTtabBar program. Sorry for my bad english. 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