How to read the contents of the listbox QuickMacro

Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, _
ByVal wMsg As Long, ByVal wParam As Long, lParam As int32) As Long
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
 LVM_GETITEMCOUNT = (&H1000 + 4)
TracePrint LVM_GETITEMCOUNT
hwnd = 265094
TracePrint SendMessage(Hwnd, LVM_GETITEMCOUNT, 0, 0) '获取ListBox项目数
LB_GETCOUNT = &H18B
LB_GETTEXT = &H189
dex = SendMessage(hwnd, LB_GETCOUNT, 0, 0)
TracePrint dex
Dim d
For i = 0 To dex-1
    s=Space(500)
    Call SendMessage(hwnd, LB_GETTEXT, i, s)
    TracePrint ANSItoUnicode(s)
Next
Function ANSItoUnicode(vIn)
    Dim i,ThisCharCode,NextCharCode,strReturn
    For i = 1 To LenB(vIn)
        ThisCharCode = AscB(MidB(vIn, i, 1))
        If ThisCharCode < &H80 Then
            strReturn = strReturn & Chr(ThisCharCode)
        Else
            NextCharCode = AscB(MidB(vIn, i + 1, 1))
            strReturn = strReturn & Chr(CLng(ThisCharCode) * &H100 + CInt(NextCharCode))
            i = i + 1
        End If
    Next
    ANSItoUnicode=strReturn
End Function
TracePrint 11

Published 10 original articles · won praise 0 · Views 4659

Guess you like

Origin blog.csdn.net/aa326358942/article/details/80357069
Recommended