0

2 我浏览了论坛和其他相关问题,但没有得到太多帮助。我的问题与使用 AutoIt 向控件发送消息有关。在下面的代码中,我试图找到我打算搜索的文本索引(“L20”)。该应用程序是用 VB 编写的,并且通过 VB 可以使用相同的 SendMessage。我相信下面的 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
4

0 回答 0