vb点击其他程序上按钮的问题(SendMessage)

SendMessage函数不太会用,前辈大师能否帮助写一段代码,实现点击指定窗体的指定按钮:需要点击:"regediter"窗口里面的"start"按钮。具体数据:"re... SendMessage函数不太会用,前辈大师能否帮助写一段代码,实现点击指定窗体的指定按钮:需要点击:"regediter"窗口里面的"start"按钮。具体数据:"regediter"窗口 的handle:00D3047A 的class:#32770 (Dialog) "start"按钮的handle:000A05EE "start"按钮的class:Button 谢谢! 展开
 我来答
匿名用户
2013-08-09
展开全部
VB6.0,用右击任务栏,属性,打开的窗口进行测试,可以按取消按钮,成功Option Explicit
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private 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
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 Declare Function SetActiveWindow Lib "user32" (ByVal hwnd As Long) As Long
Private Const BM_CLICK As Long = &HF5Private Sub Command1_Click()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "任务栏和「开始」菜单属性") '我找的是任务栏属性窗口,这里换成你要找的窗口标题
'MsgBox hwnd
Dim btnhWnd As Long
btnhWnd = FindWindowEx(hwnd, 0, "Button", "取消") '取消是按按钮的标题,你要换成自己的内容
MsgBox btnhWnd
SetActiveWindow hwndSendMessage btnhWnd, BM_CLICK, 0, 0End Sub
本回答被网友采纳
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

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

类别

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

说明

0/200

提交
取消

辅 助

模 式