标题:vb 控制外部程序问题
取消只看楼主
Muxeel_unite
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2014-11-14
 问题点数:0 回复次数:0 
vb 控制外部程序问题
我想用vb的按下按钮  想按下qq的"立即安装"按钮  我已经获得“立即安装”按钮的句柄和ID  接下来怎么做?
程序代码:
[codePrivate Declare Function WinExec Lib "kernel32" (ByVal lpCmdLine As String, ByVal nCmdShow As Long) 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 htxt0 As Long, htxt1 As Long, htxt2 As Long, htxt3 As Long, idd As Long
Private Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId 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 Const BN_CLICKED = 0
Private Const WM_COMMAND = &H111

Private Sub Command1_Click()
lngtemp = WinExec("G:\QQ6.4_6.4.12593.0.exe", 1) '返回值>32表示打开成功
End Sub

Private Sub Command2_Click()
htxt0 = FindWindowEx(0, 0, "#32770", "腾讯QQ安装向导")
Print htxt0
htxt1 = FindWindowEx(htxt0, 0, "#32770", "")
Print htxt1
htxt2 = FindWindowEx(htxt0, htxt1, "#32770", "")
Print htxt2
htxt3 = FindWindowEx(htxt2, 0, "Button", "立即安装")
Print htxt3
End Sub

Private Sub Command3_Click()
GetWindowThreadProcessId htxt3, idd
Print idd
End Sub

Private Sub Command4_Click()
SendMessage htxt2, BN_CLICKED, idd, htxt3
End Sub
]
[/code]
2014-11-14 23:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-438609-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.125661 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved