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

 我来答
shaoyedh
2011-04-20 · TA获得超过102个赞
知道小有建树答主
回答量:150
采纳率:0%
帮助的人:104万
展开全部
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
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式