注册 登录
编程论坛 VB6论坛

vb 控制外部程序问题

Muxeel_unite 发布于 2014-11-14 23:21, 571 次点击
我想用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]
0 回复
1