Jump to content

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


Recommended Posts

Is it possible that I click one row by knowing the text? for example I have lots of cases that we want to click on one record based on HeadCode, I don't like to use position;Now I have all the elements in array just needs to check if that item exists in array then click it then goes to next page, would you please help me about that?

Link to comment
Share on other sites

Please check the help file for ControlListView (already used in your script) and look for "FindItem" and "Select".

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

I've tried 2 ways as are shown below but non of them worked!!

 

For $i = 0 To $iItemCount - 1
    Local $arg = $aHeadCode[$i]
    switch $arg
        case "1C01DB"
            MsgBox($MB_SYSTEMMODAL, "", ControlListView($handle, "", "[Class:SysListView32; INSTANCE:1]", "FindItem", $i, 0)  ;First way
            _GUICtrlListView_SetItemSelected($arg, $i) ;Second way
            _GUICtrlListView_ClickItem($arg, $i)
    EndSwitch
Next

Link to comment
Share on other sites

Now I have all the items in both array and ControlListView; should I use _GUICtrlListView for click item? I did not find anything for array or ControlListView that gives click functionality....

Link to comment
Share on other sites

maybe ? :

For $i = 0 To $iItemCount - 1
    Local $arg = $aHeadCode[$i]
    switch $arg
        case "1C01DB"
            ;"FindItem", "string to find" [, SubItem]
            ;Returns the item index of the string. Returns -1 if the string is not found.
            $ControlListViewReturn = ControlListView($handle, "", "[Class:SysListView32; INSTANCE:1]", "FindItem", $arg)
            If $ControlListViewReturn = -1 Then
                Msgbox(0,"","Not Found")
            Else
                ; If found then select :
                ControlListView($handle, "", "[Class:SysListView32; INSTANCE:1]", "Select", $ControlListViewReturn)
                ; Clic on next page place
                ; ...
            EndIf
    EndSwitch
Next

 

Link to comment
Share on other sites

Sahar,

I would do two things:

  • Add some error checking so you get (and can post) more information about what goes wrong. What do the _GUICtrlListView* functions return?
  • Post a small script that we can run (not just a function) so we exactly know what you coded and we can see what goes wrong and play with the script.

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

Does pressing the "Return" or "Space" key do the same as clicking on the selected row?

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

More secure would be to use ControlSend.

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

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