SysListView问题(如何遍历其他软件SysListView的值)
我现在已经找到窗口,得到lhWnd值。现在我想控制鼠标单击SysListView的第一列值,最好能重复遍历完整个列表值。
我应该怎么做,我用了mouse_event,sendmessage,最终只能是第一列值选中,但是没有单击事件。请大家帮帮我 。感激不尽。
部分源码。
If iEditCount = 1 And WinClass = "ComboBox" Then
iChildCboHwnd = lhWnd
ElseIf iEditCount = 4 And WinClass = "Edit" Then
iChildNameHwnd = lhWnd
SendMessageByString lhWnd, WM_SETTEXT, -1, ByVal strSearchName
DoEvents
Sleep 100
ElseIf iEditCount = 7 And WinClass = "ComboBox" Then
iChildCboSexHwnd = lhWnd ElseIf iEditCount = 8 And WinClass = "Edit" Then
iChildAge1Hwnd = lhWnd
SendMessageByString lhWnd, WM_SETTEXT, -1, ByVal frmMain.txtStart.Text
DoEvents
Sleep 100
ElseIf iEditCount = 9 And WinClass = "Edit" Then
iChildAge2Hwnd = lhWnd
SendMessageByString lhWnd, WM_SETTEXT, -1, ByVal frmMain.txtEnd.Text
DoEvents
Sleep 100
ElseIf iEditCount = 13 And WinClass = "Button" And WinTitle = "검색하기" Then
iChildSearchBntHwnd = lhWnd
Call BTNclick(lhWnd)
ElseIf iEditCount = 14 And WinClass = "SysListView32" And WinTitle = "List1" Then
iChildLvHwnd = lhWnd
'SendMessage lhWnd, MK_LBUTTON, 0, 0
'MsgBox a
MouseMove 975, 504
'PostMessage lhWnd, WM_KEYDOWN, VK_RETURN, 0&
'PostMessage lhWnd, WM_KEYUP, VK_RETURN, 0&
'Sleep 500
SendMessage lhWnd, LVNI_SELECTED, 0, 0
MouseLeftClick ElseIf iEditCount = 18 And WinClass = "Edit" Then
iChildSendHwnd = lhWnd
ElseIf iEditCount = 31 And WinClass = "Button" And WinTitle = "친구요청" Then
iChildAddbntHwnd = lhWnd
ElseIf iEditCount = 36 And WinClass = "Static" Then
IChildAddOkHwnd = lhWnd
ElseIf iEditCount = 38 And WinClass = "Button" And WinTitle = "계속" Then
iChildAgainBntHwnd = lhWnd
End If
我现在已经找到窗口,得到lhWnd值。现在我想控制鼠标单击SysListView的第一列值,最好能重复遍历完整个列表值。
我应该怎么做,我用了mouse_event,sendmessage,最终只能是第一列值选中,但是没有单击事件。请大家帮帮我 。感激不尽。
部分源码。
If iEditCount = 1 And WinClass = "ComboBox" Then
iChildCboHwnd = lhWnd
ElseIf iEditCount = 4 And WinClass = "Edit" Then
iChildNameHwnd = lhWnd
SendMessageByString lhWnd, WM_SETTEXT, -1, ByVal strSearchName
DoEvents
Sleep 100
ElseIf iEditCount = 7 And WinClass = "ComboBox" Then
iChildCboSexHwnd = lhWnd ElseIf iEditCount = 8 And WinClass = "Edit" Then
iChildAge1Hwnd = lhWnd
SendMessageByString lhWnd, WM_SETTEXT, -1, ByVal frmMain.txtStart.Text
DoEvents
Sleep 100
ElseIf iEditCount = 9 And WinClass = "Edit" Then
iChildAge2Hwnd = lhWnd
SendMessageByString lhWnd, WM_SETTEXT, -1, ByVal frmMain.txtEnd.Text
DoEvents
Sleep 100
ElseIf iEditCount = 13 And WinClass = "Button" And WinTitle = "검색하기" Then
iChildSearchBntHwnd = lhWnd
Call BTNclick(lhWnd)
ElseIf iEditCount = 14 And WinClass = "SysListView32" And WinTitle = "List1" Then
iChildLvHwnd = lhWnd
'SendMessage lhWnd, MK_LBUTTON, 0, 0
'MsgBox a
MouseMove 975, 504
'PostMessage lhWnd, WM_KEYDOWN, VK_RETURN, 0&
'PostMessage lhWnd, WM_KEYUP, VK_RETURN, 0&
'Sleep 500
SendMessage lhWnd, LVNI_SELECTED, 0, 0
MouseLeftClick ElseIf iEditCount = 18 And WinClass = "Edit" Then
iChildSendHwnd = lhWnd
ElseIf iEditCount = 31 And WinClass = "Button" And WinTitle = "친구요청" Then
iChildAddbntHwnd = lhWnd
ElseIf iEditCount = 36 And WinClass = "Static" Then
IChildAddOkHwnd = lhWnd
ElseIf iEditCount = 38 And WinClass = "Button" And WinTitle = "계속" Then
iChildAgainBntHwnd = lhWnd
End If
您看看。
ElseIf iEditCount = 14 And WinClass = "SysListView32" And WinTitle = "List1" Then
iChildLvHwnd = lhWnd
'Sleep 2000
Call ListClick(lhWnd)
'Call BTNclick(lhWnd)
moudel code:
Option Explicit
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Private Declare Function SetFocusApi Lib "user32" Alias "SetFocus" (ByVal hwnd As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function AttachThreadInput Lib "user32" (ByVal idAttach As Long, ByVal idAttachTo As Long, ByVal fAttach As Long) As Long
Private Const MK_LBUTTON = &H1
Private Const WM_LBUTTONDOWN = &H201
Private Const WM_LBUTTONUP = &H202
Public Const LVNI_SELECTED = &H2
Public Const LVNI_ALL = &H0
Public Const WM_LBUTTONDBLCLK = &H203
Public Const WM_KEYDOWN = &H100
Public Const WM_SETCURSOR = &H20 Public Const VK_RETURN = &HD
Public Const WM_KEYUP = &H101
Public Sub BTNclick(ByVal mhwnd As Long)
Dim Tid1 As Long, Tid2 As Long, pid As Long
Tid1 = GetWindowThreadProcessId(mhwnd, pid)
Tid2 = App.ThreadID
Call AttachThreadInput(Tid1, Tid2, True)
SetFocusApi mhwnd
SendMessage mhwnd, WM_LBUTTONDOWN, MK_LBUTTON, ByVal &H10001
SendMessage mhwnd, WM_LBUTTONUP, MK_LBUTTON, ByVal &H10001
End SubPublic Sub ListClick(ByVal mhwnd As Long)
Dim Tid1 As Long, Tid2 As Long, pid As Long
Tid1 = GetWindowThreadProcessId(mhwnd, pid)
Tid2 = App.ThreadID
Call AttachThreadInput(Tid1, Tid2, True)
SetFocusApi mhwnd
'Sleep 1000
MouseMove 975, 504
SendMessage mhwnd, WM_KEYDOWN, VK_RETURN, 0&
PostMessage mhwnd, WM_KEYDOWN, VK_RETURN, 0&
'SendMessage mhwnd, WM_LBUTTONUP, MK_LBUTTON, 0
' SendMessage mhwnd, WM_KEYDOWN, VK_RETURN, 0
'SendMessage mhwnd, LVNI_SELECTED, MK_LBUTTON, 0
'MouseLeftClick
End Sub
这种帖子也不给分
看这里吧
http://blog.csdn.net/chenhui530/archive/2007/10/03/1810261.aspx