Jump to content

Automating double click on a subitem in a listview


Recommended Posts

Hi Everyone,

I have an window's application which is built on C++. I want to automate double click on a subitem in a listview and enter data. I have gone through _GUICtrlListView_ClickItem() function, but this doesn't allow to click on a subitem.

how can this be done??

Please help.

Link to comment
Share on other sites

As always, we help those who help themselves.

That means, that you need to present us with the code you've used so far, so that we can detect any errors you may have made and so that we don't have to code something from scratch for you.

Saves time all around, especially for us volunteers.

P.S. All except trancexx, who is a special case and doesn't want to be classed as 'we' or 'us' or even a volunteer (especially one that doesn't like getting unsolicited PM's). :blink::evil::lmao::mad2:

Make sure brain is in gear before opening mouth!
Remember, what is not said, can be just as important as what is said.

Spoiler

What is the Secret Key? Life is like a Donut

If I put effort into communication, I expect you to read properly & fully, or just not comment.
Ignoring those who try to divert conversation with irrelevancies.
If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it.
I'm only big and bad, to those who have an over-active imagination.

I may have the Artistic Liesense ;) to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage)

userbar.png

Link to comment
Share on other sites

To automate the listview of another application function ControlGetHandle seems to be a good starting point.

But, as The Saint already said, post what you have already tried and we will see how we can help.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.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 (NEW 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

  • 5 months later...

Here is a scent

But... I've got absolutely no idea of how this can work or not on an external listview  (not tested)

#include <GuiConstantsEx.au3>
#include <GuiListView.au3>
#include <WindowsConstants.au3>

$gui = GUICreate("", 300, 450)
Local $listView = GUICtrlCreateListView("A|B|C|D|E|F|G", 20, 20, 250, 350, -1, $LVS_EX_GRIDLINES)
For $i = 0 To 20
    GUICtrlCreateListViewItem("A" & $i & "|B" & $i & "|C" & $i & "|D" & $i & "|E" & $i & "|F" & $i & "|G" & $i, $listView)
Next
$listView = GUICtrlGetHandle($listView) ;the example didn't work when used with ControlID.
$label1 = GuiCtrlCreateLabel("item", 50, 380, 50, 17)
$input1 = GuiCtrlCreateInput("1", 100, 380, 30, 17)
$label2 = GuiCtrlCreateLabel("subitem", 50, 400, 50, 17)
$input2 = GuiCtrlCreateInput("1", 100, 400, 30, 17)
$btn = GuiCtrlCreateButton("click", 150, 390, 50, 25)
GUISetState()


Do
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $btn
             $it = GuiCtrlRead($input1)+1
             $subit = GuiCtrlRead($input2)
             $aRect = _GUICtrlListView_GetSubItemRect($listView, $it, $subit)
             $iX = ($aRect[0]+$aRect[2])/2
             $iY = ($aRect[1]+$aRect[3])/2
             _GUICtrlListView_EnsureVisible($listView, 2, True)
             Local $iMode = Opt("MouseCoordMode", 2)
             Local $aPos = MouseGetPos()
             _WinAPI_ShowCursor(False)
             MouseClick("left", $iX, $iY, 2, 1)

      $sSubitem = GetItemClicked($listView)  ; <<<< this is for the test
             MouseMove($aPos[0], $aPos[1], 0)
            _WinAPI_ShowCursor(True)
            Opt("MouseCoordMode", $iMode)

      If $sSubitem <>"" Then Msgbox(0,"", $sSubitem & ": was clicked")   ; <<<< this too

    EndSwitch
Until $nMsg = $GUI_EVENT_CLOSE


Func GetItemClicked( $hListView )
    $aInfo = _GUICtrlListView_SubItemHitTest( $hlistView )
    If $aInfo[0] = -1 Or $aInfo[1] = -1 Then Return SetError(2, 0, -1)
    If IsArray($aInfo) = 0 Then Return SetError(1, 0, -1)
    ;get the item/subitem text.
    Return _GUICtrlListView_GetItemText($hlistView, $aInfo[0], $aInfo[1])
EndFunc
Edited by mikell
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...