
我有原代码,给你吧,很好用的,你所要求的它都可以实现,界面如图。
使用很简单:启动后将鼠标移到别的软件的LISTBOX,按F5,软件LISTBOX的内容就被复制到它的LISTBOX中了。最下面是代码工程的下载地址:
‘Module1------------------------------
Option Explicit
Type POINTAPI
x As Long
y As Long
End Type
Public Const LB_GETTEXT = &H189
Public Const LB_GETCOUNT = &H18B
Public Declare Function SendMessageBynum& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long)
Public Declare Function SendMessageByString& Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String)
Public Declare Function GetAsyncKeyState Lib "user32" (ByVal vkey As Long) As Integer
Public Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long
Public Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function EnumChildWindows Lib "user32" (ByVal hWndParent As Long, ByVal lpEnumFunc As Long, ByVal lParam As Long) As Long
Public Function EnumWindows_CBK(ByVal hwnd As Long, ByVal lParam As Long) As Long
Form1List1AddItem Str(hwnd)
EnumWindows_CBK = 1
End Function
’Form1--------------------------------
Option Explicit
Dim win As Long
Dim wintxt As String
Dim i As Integer
Dim MyStr As String
Dim xy As POINTAPI
Dim kq As Boolean
Dim txt As String
Private Sub Form_Load()
kq = False
End Sub
Private Sub List1_Click()
If List1ListIndex >= 0 Then Text4 = List1List(List1ListIndex)
End Sub
Private Sub List2_Click()
If List2ListIndex >= 0 Then Text5 = List2List(List2ListIndex)
End Sub
Private Sub Timer1_Timer()
Dim i As Long
Dim TListCount As Long
Dim TListTexts As String
GetCursorPos xy
win = WindowFromPoint(xyx, xyy)
MyStr = String(100, Chr$(0))
List1Clear
EnumChildWindows win, AddressOf EnumWindows_CBK, 1
Text1Text = List1ListCount
For i = 0 To List1ListCount - 1
GetWindowText Val(List1List(i)), MyStr, 100
List1List(i) = List1List(i) & " " & MyStr
Next
txt = String(100, Chr$(0))
GetWindowText win, txt, 100
Text2Text = Str(win) & " " & txt
TListCount = SendMessageBynum&(win, LB_GETCOUNT, 0&, 0&)'得到项目数
Text3 = TListCount
List2Clear
For i = 0 To TListCount - 1'将内容添加到列表框
TListTexts = String$(255, 0)
SendMessageByString& win, LB_GETTEXT, i, TListTexts
TListTexts = Left$(TListTexts, InStr(1, TListTexts, Chr$(0)) - 1)
List2AddItem TListTexts
Next i
End Sub
Private Function MyHotKey(vKeyCode) As Boolean
MyHotKey = (GetAsyncKeyState(vKeyCode) < 0)
End Function
Private Sub Timer2_Timer()
If MyHotKey(vbKeyF5) Then
If kq = False Then
Timer1Enabled = True
kq = True
Else
Timer1Enabled = False
kq = False
End If
End If
End Sub
原代码工程下载地址:
>
我正好有原码:
使用很简单:
运行后将鼠标移到你要的窗口,如果是一个Listbox,它的内容将被复制到程序的List2控件。
>
以上就是关于VB 用API读取别的软件的LISTBOX中的某项和项目的总数全部的内容,包括:VB 用API读取别的软件的LISTBOX中的某项和项目的总数、VB用API读取LISTBOX中的每一项的内容和项的总数.、等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)