Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName 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 FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long Private Const BM_CLICK = &HF5 Dim ts As String Dim an As String Private Sub Timer1_Timer() pk = FindWindow(vbNullString, 窗体名) pp = FindWindowEx(pk, ByVal 0&, "Button", 按钮名) SendMessage pp, BM_CLICK, 0, 0 End Sub 模拟点击窗体A上的按钮 但发现窗体A时 点击显示B
B.Show
End Sub
不是很明白你的意思……
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 FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Const BM_CLICK = &HF5
Dim ts As String
Dim an As String
Private Sub Timer1_Timer()
pk = FindWindow(vbNullString, 窗体名)
pp = FindWindowEx(pk, ByVal 0&, "Button", 按钮名)
SendMessage pp, BM_CLICK, 0, 0
End Sub
模拟点击窗体A上的按钮 但发现窗体A时 点击显示B