请问,如何获取其他程序某一个控件中的文本信息?VB6实现,最好有实例可以参考。谢谢!

如题所述

Option Explicit

Private Type POINTAPI
x As Long
y As Long
End Type
Private Declare Function SetWindowText Lib "user32" Alias "SetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String) As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Declare Function GetCursorPos Lib "user32 " (lpPoint As POINTAPI) As Long
Private Declare Function WindowFromPoint Lib "user32 " (ByVal x As Long, ByVal y As Long) As Long

Dim Cur As POINTAPI

Private Sub Command1_Click()
Me.Caption = SetWindowText(Val(Text1.Text), "啦啦啦啦!~")
End Sub

Private Sub Timer1_Timer()

Dim hwnd1 As Long, mystr As String
GetCursorPos Cur
hwnd1 = WindowFromPoint(Cur.x, Cur.y)
Label1.Caption = hwnd1
mystr = String(100, Chr$(0))
If hwnd1 > 1 Then
GetWindowText hwnd1, mystr, 100
Text2.Text = mystr
End If
End Sub
用timer控制获取鼠标位置所指的hwnd 和text
温馨提示:答案为网友推荐,仅供参考
相似回答