Sign in to follow this  
Followers 0
jorjica

Cannot double click item in listview

12 posts in this topic

Hello

I'm trying to automate SeNuke. The main window is composed out of 3 controllers. The right side one si a list view controller, and I cannot double click a item (any item) from it. I need to double click the item because double clicking will open a new window.

I've tired with ControlClick with exact coordonates or with coordonates that I got from _GUICtrlListView_GetItemPositionX. I can click the item, is becomes selected, the funcrtion resturns 1, but it does only one click (or more than one but it does not open the window that I need).

I've tried with _GUICtrlListView_ClickItem and the same thing happens. I'm sure that I got the right controller because all the orher functions works.

I've tried to focus the item first, to pause between clicks, but nothing works.

I don't know that to try.

Any ideeas?

Thanks.

Share this post


Link to post
Share on other sites



I tried something like this:

$tree = ControlGetHandle($t_start,"","WindowsForms10.SysListView32.app.0.2bf8098_r15_ad11")

$x = _GUICtrlListView_GetItemPositionX($tree,0)

$y = _GUICtrlListView_GetItemPositionY($tree,0)

$r = ControlClick($t_start,"","[NAME:ListView1]","left",2,$x,$y)

Sleep(100)

$r = ControlClick($t_start,"","[NAME:ListView1]","left",2,$x,$y)

MsgBox(0,"",$r) - it's 1

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

I'm working on listview in the last few days, this might help

#include <GUIConstantsEx.au3>
#include <ListViewConstants.au3>
#include <WindowsConstants.au3>
#include <GuiListView.au3>
#include <GuiMenu.au3>
#include <ListViewConstants.au3>
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Form1", 383, 165, 281, 391)
$List = _GUICtrlListView_Create($Form1, "", 8, 8, 362, 150)
_GUICtrlListView_SetExtendedListViewStyle($List, BitOR($LVS_EX_GRIDLINES, $LVS_EX_FULLROWSELECT, $LVS_EX_SUBITEMIMAGES))
_GUICtrlListView_InsertColumn($List, 0, "Name", 160)
_GUICtrlListView_InsertColumn($List, 1, "Company", 140)
_GUICtrlListView_InsertColumn($List, 2, "Quotes", 50)
_GUICtrlListView_AddItem($List, 'John', 0)
_GUICtrlListView_AddSubItem($List, 0, 'Troll Tech', 1)
_GUICtrlListView_AddSubItem($List, 0, 'None', 2)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit

EndSwitch
WEnd

Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndListView, $tInfo
$hWndListView = $List
If Not IsHWnd($List) Then $hWndListView = GUICtrlGetHandle($List)

$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndListView
Switch $iCode
Case $NM_RCLICK
ConsoleWrite("Right click at listview")
ListView_RClick()
Return 0
Case $NM_DBLCLK  ; Sent by a list-view control when the user double-clicks an item with the left mouse button
Local $tInfo = DllStructCreate($tagNMITEMACTIVATE, $ilParam)
$Index = DllStructGetData($tInfo, "Index")
$subitemNR = DllStructGetData($tInfo, "SubItem")
ConsoleWrite("Double click at item index: "&$Index&@CRLF)
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc

Func ListView_RClick()
Local $mipost,$numsel, $open, $exit
$mipost = _GUICtrlListView_SubItemHitTest($List)
If ($mipost[0] <> -1) Then
$hMenu = _GUICtrlMenu_CreatePopup()
_GUICtrlMenu_AddMenuItem($hMenu, "Open", $open)
_GUICtrlMenu_AddMenuItem($hMenu, "")
_GUICtrlMenu_AddMenuItem($hMenu, "Exit",$exit)
;>>>>>>>>>>>>>>>>>>> Seleccion menu Contextual <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

Switch _GUICtrlMenu_TrackPopupMenu($hMenu, $List, -1, -1, 1, 1, 2)
Case $open
$numsel=_GUICtrlListView_GetItemText($List, $mipost[0],0)
MsgBox(0,"","You clicked in "&$numsel&@CRLF&"index:"&$mipost[0])
;_GUICtrlListView_DeleteAllItems($Lista)
;Listar()
Case $exit
Exit
EndSwitch
_GUICtrlMenu_DestroyMenu($hMenu)
EndIf
EndFunc
Edited by DiOgO

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

I'm still a beginner at autoit, but I think that I want to double click an item into an application, not to catch a double click on my own GUI application.

Share this post


Link to post
Share on other sites

I'm still a beginner at autoit, but I think that I want to double click an item into an application, not to catch a double click on my own GUI application.

ah, ok, I never done click automation, etc, you need first activate the window, then do the click (with listview you have more trouble to identify items)

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

I can identify the item. I can even get the item's text with _GUICtrlListView_GetItemText. But I cannot double click it :(

Share this post


Link to post
Share on other sites

And about activating the window, my code starts with:

WinWaitActive($t_start)

Sleep(100)

so it waits for the right window to pe active.

Share this post


Link to post
Share on other sites

I can identify the item. I can even get the item's text with _GUICtrlListView_GetItemText. But I cannot double click it :(

if you can get item text, you have the index + listview handle, then try this:

_GUICtrlListView_ClickItem($hListView,$index,"left",False,2)

$hListView = listview handle


Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

Now it works. And I've tried many times with _GUICtrlListView_ClickItem function :))

The only thing that was different was the parameters in lowercase (false) that i was using. Does the case-sensitivity matters here?

Share this post


Link to post
Share on other sites

Now it works. And I've tried many times with _GUICtrlListView_ClickItem function :))

The only thing that was different was the parameters in lowercase (false) that i was using. Does the case-sensitivity matters here?

I think it doesn't, but if you start to write false in scite, it autocompletes with False :)

Heroes, there is no such thing

One day I'll discover what IE.au3 has of special for so many users using it.
C'mon there's InetRead and WinHTTP, way better
happy.png

Share this post


Link to post
Share on other sites

Thank you.

Ok, now I'm moving closer and I've noticed another problem.

In the left site there is a treeview control, and in the right side there is a listview control. I can only click the item from the listview control after I restart the application and only if I do not touch anything from the left treeview control. I've tried with controlfocus() and the function works but I still cannot double click the item.

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