How do I remotely DoubleClick an Item in a ListBox

I am trying to send select an Item in a remote listbox using

Call SendMessageByString(x, LB_SELECTSTRING, 0&, "Item")

and then send

Call SendMessage(x, WM_LBUTTONDBLCLK, 0&, 0&)

so that the listbox item is clicked. However this does not work.

I have tried to use

Call SendMessageByObject(x, WM_LBUTTONUP, 0&, 0)
Call SendMessageByObject(x, WM_LBUTTONDOWN, 0&, 0)
Call SendMessage(x, WM_LBUTTONDBLCLK, 0&, 0&)

But this just selects the first item in the list box, how can I use this sequence to select the item I want?

Thanks,
VeedenAsked:
Who is Participating?
 
danaseamanConnect With a Mentor Commented:
To get Mouse coordinates relative to a control use this code where m_hWnd is the handle of control:

Private Type POINTAPI    
   x    As Long
   y    As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Private Declare Function ScreenToClient Lib "user32" (ByVal hwnd As Long, lpPoint As POINTAPI) As Long

Dim pt As POINTAPI
GetCursorPos pt
ScreenToClient m_hWnd, pt
0
 
angus_young_acdcCommented:
I'm guessing that the last 0 in the sequence is an index number.  In which case it will go to index 0 (which is generally the first in the list).  Try changing that value to the item you want and it should work.
0
 
danaseamanCommented:
Try this:

Call SendMessageByString(x, LB_SELECTSTRING, -1&, ByVal "Item")
Change "Item" to the caption of Item you want to select.

0
 
VeedenAuthor Commented:
I changed it to the code below. The same effect happens, the listbox opens the row "item" gets selected however, when WM_LBUTTONDBLCLK is issued the selected item does not get clicked.
     Call SendMessageByString(x, LB_SELECTSTRING, -1&, DesktopTitle)
     Call SendMessage(x, WM_LBUTTONDBLCLK, 0&, 0&)

Open in new window

0
 
VeedenAuthor Commented:
Also EddieShipman mentioned ( http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22637243.html?sfQueryTermInfo=1+click+listbox)

how to do this, but I cant get the mouse coordinates to work properly
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.