vb如何获取另外一个程序的控件类名或id

vb中如何获取一个程序(不是自己编的)的控件的类名或id?... vb中如何获取一个程序(不是自己编的)的控件的类名或id? 展开
 我来答
百度网友946091171
2012-02-26 · 超过12用户采纳过TA的回答
知道答主
回答量:53
采纳率:0%
帮助的人:36万
展开全部
帮忙补充一下声明,然后就可以用了

Private Declare Function GetCursorPos Lib "user32" (lpPoint As Any) As Long
Private Declare Function WindowFromPoint Lib "user32" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Type POINTAPI
x As Long
y As Long
End Type

Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1
End Sub

Private Sub Timer1_Timer()
On Error Resume Next
Dim tPoint As POINTAPI
Dim hWin As Long
Dim str As String * 255
Dim abc As String * 64000
Dim Txt(64000) As Byte
GetCursorPos tPoint
hWin = WindowFromPoint(tPoint.x, tPoint.y)
If hWin = Me.hwnd Then Exit Sub
GetClassName hWin, str, 255
SendMessage hWin, &HD, 64000, Txt(0)
Me.Caption = "窗口类:" & str
End Sub
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
莫纳的丝绒
2011-08-10 · TA获得超过105个赞
知道小有建树答主
回答量:96
采纳率:0%
帮助的人:126万
展开全部
一个按钮,一个时钟
Private Sub Command1_Click()
Timer1.Enabled = True
Timer1.Interval = 1
end sub

Private Sub Timer1_Timer()
On Error Resume Next
Dim tPoint As POINTAPI
Dim hWin As Long
Dim str As String * 255
Dim abc As String * 64000
Dim Txt(64000) As Byte
GetCursorPos tPoint
hWin = WindowFromPoint(tPoint.x, tPoint.y)
If hWin = Me.hwnd Then Exit Sub
GetClassName hWin, str, 255
SendMessage hWin, &HD, 64000, Txt(0)
me.Caption = "窗口类:" & str
End Sub

鼠标整哪儿,就取哪儿的类名
本回答被提问者采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式