Function FindWnd(Phwnd As Long, ClassName As String, Index) As Long
Dim i As Integer, ChildHwnd As Long
ChildHwnd = FindWindowEx(Phwnd, 0, ClassName, vbNullString)
Do While ChildHwnd
i = i + 1
If i = Index Then
FindWnd = ChildHwnd
Exit Do
End If
ChildHwnd = FindWindowEx(Phwnd, ChildHwnd, ClassName, vbNullString)
Loop
End Function
二、函數調用舉例:
如果妳要查找計算器內第4個"Button",且不管其標題,那麽這樣調用:
dim i as long,Phwnd as long
Phwnd = FindWindow(vbNullString, "計算器")
i=FindWnd(Phwnd, "Button", 4)