Sahar

Find a control by ID and put all it's items in an array or list

30 posts in this topic

I am new to autoit, I have a window contains a list of items and I need to catch each item separately, so I was thinking there should be one way to put these items in an array and work with them, I should mention that the whole window has only one ID and each item on the window doesn't have an individual distinguisher. Would you please guide me that how I can find the control by ID and put all the items in a list or array?

Thank you

Share this post


Link to post
Share on other sites



Welcome to AutoIt and the forum!

You need to provide a bit more information for us to help you.
Could you please post a screenshot of the window so we know what we are talking about?


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

 

I need to have each column in a separate array...

Share this post


Link to post
Share on other sites

TTlist.png

Share this post


Link to post
Share on other sites

What does the Autoit Window Info Tool display for the table control? ControlId etc.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

control.png

Share this post


Link to post
Share on other sites

You would need something like this:

#include <Array.au3>
Global $sTitle = "ArrayDisplay" ; <== Set the title of your window here
Global $iItemCount = ControlListView($sTitle, "", "[Class:SysListView32]", "GetItemCount")
Global $aHeadCode[$iItemCount]
Global $aDescription[$iItemCount]
Global $aDepart[$iItemCount]
For $i = 0 To $iItemCount - 1
    $aHeadCode[$i] = ControlListView("ArrayDisplay", "", "[Class:SysListView32]", "GetText", $i, 0)
    $aDescription[$i] = ControlListView("ArrayDisplay", "", "[Class:SysListView32]", "GetText", $i, 1)
    $aDepart[$i] = ControlListView("ArrayDisplay", "", "[Class:SysListView32]", "GetText", $i, 2)
Next
_ArrayDisplay($aHeadCode)
_ArrayDisplay($aDescription)
_ArrayDisplay($aDepart)

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Hi Water,

Thanks for your reply, I've tried that code but always  $iItemCount iz zero!

Global $sTitle = "Timetables" ; <== Set the title of your window here
    Global $iItemCount = ControlListView($sTitle, "","[Class:SysListView32]", "GetItemCount")

    Global $aHeadCode[$iItemCount]
    Global $aDescription[$iItemCount]
    Global $aDepart[$iItemCount]
    For $i = 0 To $iItemCount - 1
        $aHeadCode[$i] = ControlListView("Timetables", "", "[Class:SysListView32]", "GetText", $i, 0)
        $aDescription[$i] = ControlListView("Timetables", "", "[Class:SysListView32]", "GetText", $i, 1)
        $aDepart[$i] = ControlListView("Timetables", "", "[Class:SysListView32]", "GetText", $i, 2)
    Next
    _ArrayDisplay($aHeadCode)
    _ArrayDisplay($aDescription)
    _ArrayDisplay($aDepart)

array.png

Share this post


Link to post
Share on other sites

Do I need to mention control ID which is "1310" in  ControlListView ? now we haven't addressed  which control do we want to be found...

Share this post


Link to post
Share on other sites
Global $sTitle = "Timetables" ; <== Set the title of your window here

I think your problem is here. With your screenshot on post #6, windows info Title seems be "" and not "Timetables".

Maybe u can try ControlListView but with winhandle ? Sample :

Local $hHWiNFO = WinGetHandle("[REGEXPTITLE:HWiNFO(.*) Sensor Status]")
consolewrite($hHWiNFO & @CRLF); this return 0x00090376
Global $iItemCount = ControlListView($hHWiNFO, "", "[Class:SysListView32]", "GetItemCount")
consolewrite($iItemCount & @CRLF); this return 112

 

Share this post


Link to post
Share on other sites

When I am using : 

Local $hHWiNFO = WinGetHandle("[REGEXPTITLE:HWiNFO(.*) Sensor Status]")

window handle is coming as 0x00000000

handle.png

Share this post


Link to post
Share on other sites

Can you please post the "Window" tab from the AutoIt Window Info Tool? So we get as much information about the window as possible.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites
Quote

When I am using : 

Local $hHWiNFO = WinGetHandle("[REGEXPTITLE:HWiNFO(.*) Sensor Status]")

window handle is coming as 0x00000000

it's just a sample u need adapt it for u.

u can probably look around winlist, etc...

anyway @water suggest are good, give us a screenshot with

Quote

"Window" tab from the AutoIt Window Info Tool

 

1 person likes this

Share this post


Link to post
Share on other sites

Thre screenshot from post #11 shows that the window does not have a title ("Basic Window Info"). So it seems you need to use the Class:

Global $iItemCount = ControlListView([CLASS:#32770], "", "[Class:SysListView32]", "GetItemCount")

 

1 person likes this

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

As you've advised I used class in ControlListView but I am receiving syntax error!

error.png

Share this post


Link to post
Share on other sites

That would be because you didn't surround the parameter in quotes.

Should be "[CLASS:#32770]"

 

1 person likes this

√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Thanks JLogan3o13, I've put double quotes so there isn't syntax error anymore but $iItemCount is displayed as zero!

 MsgBox("","",$iItemCount)

 

Share this post


Link to post
Share on other sites
#include <Array.au3>; for _ArrayDisplay

$aWinList = WinList("[CLASS:#32770]")
_ArrayDisplay($aWinList)

For $i = 1 to $aWinList[0][0]

    ;If $aWinList[$i][0] = "" Then

        $iItemCount = ControlListView($aWinList[$i][1], "", "[Class:SysListView32]", "GetItemCount")
        ConsoleWrite($iItemCount & @CRLF)

    ;EndIf

Next

 

1 person likes this

Share this post


Link to post
Share on other sites

#19 ·  Posted (edited)

Many #32770 windows exist in the background, so you might check first which one is visible

#include <Array.au3>; for _ArrayDisplay

$aWinList = WinList("[CLASS:#32770]")
;_ArrayDisplay($aWinList)

Local $handle
For $i = 1 to $aWinList[0][0]
  If BitAND(WinGetState($aWinList[$i][1]), 2) Then  ; is the window visible ?
      $handle = $aWinList[$i][1]
      Exitloop
  EndIf
Next
$iItemCount = ControlListView($handle, "", "[Class:SysListView32; INSTANCE:1]", "GetItemCount")
Msgbox(0,"", $iItemCount)
; etc

 

Edited by mikell
many typos :)
1 person likes this

Share this post


Link to post
Share on other sites

#20 ·  Posted (edited)

Thanks everybody, now I am able to put each column in an array and work with it, this is the code that is working for me and you guys helped me alot to write:

 

$aWinList = WinList("[CLASS:#32770]")

Local $handle
For $i = 1 to $aWinList[0][0]
  If BitAND(WinGetState($aWinList[$i][1]), 2) Then  ; is the window visible ?
      $handle = $aWinList[$i][1]
      Exitloop
  EndIf
Next
$iItemCount = ControlListView($handle, "", "[Class:SysListView32; INSTANCE:1]", "GetItemCount")

Global $aHeadCode[$iItemCount]
Global $aDescription[$iItemCount]
Global $aDepart[$iItemCount]

For $i = 0 To $iItemCount - 1
    $aHeadCode[$i] = ControlListView($handle, "", "[Class:SysListView32; INSTANCE:1]", "GetText", $i, 0)
    $aDescription[$i] = ControlListView($handle, "", "[Class:SysListView32]", "GetText", $i, 1)
    $aDepart[$i] = ControlListView($handle, "", "[Class:SysListView32]", "GetText", $i, 2)
Next
_ArrayDisplay($aHeadCode)
_ArrayDisplay($aDescription)
_ArrayDisplay($aDepart)
 

Edited by Sahar

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