Jump to content

Recommended Posts

  • 4 weeks later...
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
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
  • 6 months later...
  • 1 month later...
Posted

Awesome

Thanks for sharing

mLipok

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 Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

Thanks

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

  • 1 year later...
Posted
Posted (edited)

@LarsJ 

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

Edited by kcvinu
  Reveal hidden contents

 

Posted

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.

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

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 Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

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.

Posted

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 Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

  • 1 month later...
Posted

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.

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...