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 Sub Command1_Click() Dim lngCalacHwnd As Long Dim lngButtonOneHwnd As Long Dim lngP As Long
lngCalacHwnd = FindWindow(vbNullString, "计算器") If lngCalacHwnd = 0 Then Exit Sub lngButtonOneHwnd = FindWindowEx(lngCalacHwnd, 0, vbNullString, "1") Me.PSet (100, 100) Print "计算器窗口的句柄是:" & CStr(lngCalacHwnd) Print "按钮“1”的句柄是:" & CStr(lngButtonOneHwnd) End Sub