Autoit UIA obtains the listview Information

Source: Internet
Author: User
#include "CUIAutomation2.au3"Opt( "MustDeclareVars", 1 )Global $oUIAutomationMainFunc()Func MainFunc()  ; Be sure to use the right class if you are on Vista or Windows 8  Local $hWindow = WinGetHandle( "[CLASS:CabinetWClass]", "" )  ; Windows Explorer, Windows 7  ;Local $hWindow = WinGetHandle( "[CLASS:ExploreWClass]", "" ) ; Windows Explorer, Windows XP  If Not $hWindow Then Return  $oUIAutomation = ObjCreateInterface( $sCLSID_CUIAutomation, $sIID_IUIAutomation, $dtagIUIAutomation )  If Not IsObj( $oUIAutomation ) Then Return  Local $pWindow  $oUIAutomation.ElementFromHandle( $hWindow, $pWindow )  If Not $pWindow Then Return  Local $oWindow = ObjCreateInterface( $pWindow, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )  If Not IsObj( $oWindow ) Then Return  ListAllItems( $oWindow, 50007 ) ; 50007 = List view element  ; Run the code in post #71 to get this valueEndFuncFunc ListAllItems( $oWindow, $iCtrlType )  Local $pCondition  $oUIAutomation.CreatePropertyCondition( $UIA_ControlTypePropertyId, $iCtrlType, $pCondition )  If Not $pCondition Then Return  Local $pUIElementArray, $oUIElementArray, $iElements  $oWindow.FindAll( $TreeScope_Descendants, $pCondition, $pUIElementArray )  $oUIElementArray = ObjCreateInterface( $pUIElementArray, $sIID_IUIAutomationElementArray, $dtagIUIAutomationElementArray )  $oUIElementArray.Length( $iElements )  If Not $iElements Then Return  Local $pUIElement, $oUIElement, $name, $sel  For $i = 0 To $iElements - 1    $oUIElementArray.GetElement( $i, $pUIElement )    $oUIElement = ObjCreateInterface( $pUIElement, $sIID_IUIAutomationElement, $dtagIUIAutomationElement )    $oUIElement.GetCurrentPropertyValue( $UIA_NamePropertyId, $name )    $oUIElement.GetCurrentPropertyValue( $UIA_SelectionItemIsSelectedPropertyId, $sel )    ConsoleWrite( $name & "  " & $sel & @CRLF )  NextEndFunc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.