Jump to content

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


Recommended Posts

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

Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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)

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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

Link to comment
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

 

Link to comment
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 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
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")

 

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • Moderators

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

Should be "[CLASS:#32770]"

 

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

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 :)
Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

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