将消息发送到AutoIt以获取VB6列表框和查找字符串?

时间:2013-10-07 17:36:24

标签: vb6 listbox autoit sendmessage

2    我浏览了论坛和其他相关问题,但没有得到太多帮助。    我的问题与使用AutoIt向控件发送消息有关。在下面的代码中,我试图找到我打算搜索的文本索引(“L20”)。该应用程序是用VB编写的,同样的SendMessage通过VB工作。我相信下面的SendMessage存在一些问题。请帮我找到问题。

$WindowName = "Form1"
$WindowText = ""
WinWait("[CLASS:ThunderRT6FormDC]")
Local $hListBox1 = ControlGetHandle("[CLASS:ThunderRT6FormDC]", "", "ThunderRT6ListBox1")
Local $hListBox2 = ControlGetHandle("[CLASS:ThunderRT6FormDC]", "", "ThunderRT6ListBox2")
WinActivate( $WindowName, $WindowText )
ControlClick("[CLASS:ThunderRT6FormDC]", "", "ThunderRT6ListBox2")
MsgBox(0, "ControlGetHandle Example", $hListBox1 & " - " & $LB_FINDSTRING & " - " & -1 & " - " & "L20")
MsgBox(0, "ControlGetHandle Example", $hListBox2 & " - " & $LB_FINDSTRING & " - " & -1 & " - " & "L20")
Local $sText = "L20"
Local $obj1 = DllCall("user32.dll", "int", "SendMessageA", "hwnd", $hListBox1, "UINT",     $LB_FINDSTRING, "WPARAM", -1, "wstr", $sText)
Local $obj2 = DllCall("user32.dll", "int", "SendMessageA", "hwnd", $hListBox2, "UINT", $LB_FINDSTRING, "WPARAM", -1, "wstr", $sText)
;Local $obj1 = _SendMessageA($hListBox1, $LB_FINDSTRING, -1, "L20")
;Local $obj2 = _SendMessageA($hListBox2, $LB_FINDSTRING, -1, "L20")
MsgBox(0, "ControlGetHandle Example", "The control handle of ThunderRT6ListBox1 is: " & $obj1 & $obj2)

以下vb6版本适用于VB6应用程序

If FindExactMatch Then
    GetListBoxIndex = SendMessage(hWnd, LB_FINDSTRINGEXACT, StartIndex, SearchKey)
Else
    GetListBoxIndex = SendMessage(hWnd, LB_FINDSTRING, StartIndex, SearchKey)
End If

0 个答案:

没有答案