Sign in to follow this  
Followers 0
Automationuser

Automating double click on a subitem in a listview

10 posts in this topic

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.

Share this post


Link to post
Share on other sites



Hell All,

Can someone help me on this?

I tried a lot, but still not able to get the solution

Share this post


Link to post
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:


AutoIt.4.Life Clubrooms - Life is like a Donut (secret key)

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

Share this post


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

$HWD=controlgethandle("TestApp","","[CLASS:SysListView32; INSTANCE:1]")

_GUICtrlListView_ClickItem($HWD,0," "," ",2)

I want to double click on the subitem of the index 0

Share this post


Link to post
Share on other sites

Hi Guys,

Can anyone help me with this.

Still I am not able to double click on the second column in a list view

Share this post


Link to post
Share on other sites

If you use the dbleclick optional parameter then you must define the preceding ones

Did you try

_GUICtrlListView_ClickItem($HWD, 0, "left", False, 2)

Share this post


Link to post
Share on other sites

@Mikell,

I want to double click on the subitem. _GUICtrlListView_ClickItem() doesn't have subitem parameter.

Share this post


Link to post
Share on other sites

#9 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Thanks Mikell,

This doesn't work on external application :(

Is there any other way. to do this??

Or _GUICtrlListView_ClickItem() should be modified to include subitem?

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
Sign in to follow this  
Followers 0