LarsJ

Automating Windows Explorer

48 posts in this topic




Well done

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

ingeniously!

How do you describe the "interface_description". Do you have a parser h/idl files? or do everything manually?

Edited by Inververs

Share this post


Link to post
Share on other sites

#6 ·  Posted (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 by LarsJ
1 person likes this

Share this post


Link to post
Share on other sites

Awesome

Thanks for sharing

mLipok

1 person likes this

Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  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 *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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) * 

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 *

"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"
:naughty:  :ranting:, 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: 2017-06-04

Share this post


Link to post
Share on other sites

Thanks


K L M
------------------
Real Fakenamovich
------------------
K L M
------------------
Real Fakenamovich
------------------

Share this post


Link to post
Share on other sites

#10 ·  Posted (edited)

Any chance to perform a search using your UDF?

GEXm6.png

Edited by maniootek

Share this post


Link to post
Share on other sites

#13 ·  Posted (edited)

@LarsJ 

Thanks for those examples. I think that should be placed in wiki. :) 

Edited by kcvinu

My Contributions

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)

 

Share this post


Link to post
Share on other sites

junkew, Interesting interface. I've never used it.

I hope to do it with a few more simple steps:

  1. Set the start folder for the search (example 2 above)
  2. Fill out the search field in the same way as this
  3. Wait some time while the search is performed until the count of items (example 3) is stable
  4. 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.

1 person likes this

Share this post


Link to post
Share on other sites

#15 ·  Posted (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

#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 by LarsJ
1 person likes this

Share this post


Link to post
Share on other sites

#16 ·  Posted (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 by junkew

Share this post


Link to post
Share on other sites

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:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  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 *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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) * 

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 *

"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"
:naughty:  :ranting:, 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: 2017-06-04

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

Thanks


Signature beginning:   Wondering who uses AutoIT and what it can be used for ?
* GHAPI UDF - modest begining - comunication with GitHub REST API *
ADO.au3 UDF     POP3.au3 UDF     XML.au3 UDF    How to use IE.au3  UDF with  AutoIt v3.3.14.x  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 *

My contribution to others projects or UDF based on  others projects: * _sql.au3 UDF  * POP3.au3 UDF *  RTF Printer - UDF * XML.au3 - BETA * ADO.au3 UDF SMTP Mailer UDF *

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 * Best coding practices * 

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) * 

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 *

"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"
:naughty:  :ranting:, 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: 2017-06-04

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now