我正在尝试使用SendMessage函数获取窗口文本。但是,我可以获得文本的长度,但我无法获得文本。我想TXM的字符串(String)类型不正确。感谢。
Const WM_SETTEXT = &HC
Const WM_GETTEXT = &HD
Const WM_GETTEXTLENGTH = &HE
Dim hwnd As Long
Dim hwnd_child As Long
Dim result As Long
Dim txtlen As Long
Dim txt As String
hwnd = FindWindow(vbNullString, "İngilizce Türkçe Sözlük")
hwnd_child = FindWindowEx(hwnd, 0, "Edit", vbNullString)
txtlen = SendMessage(hwnd_child, WM_GETTEXTLENGTH, 0, 0)
s = Space$(txtlen + 1)
result2 = SendMessage(hwnd_child, WM_GETTEXT, ByVal txtlen, txt)
MsgBox txt