Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Timer1_Timer()
Dim h As Long, r As RECT
h = FindWindow(vbNullString, "窗口标题") '取该窗体的句柄
GetWindowRect h, r
Text1 = "左上角坐标(" & r.Left & "," & r.Top & ")" '左上角坐标
Text2 = "右下角坐标(" & r.Right & "," & r.Bottom & ")" '右下角坐标
Text3 = "窗口高" & r.Bottom - r.Top '窗口高
Text4 = "窗口宽" & r.Right - r.Left '窗口宽
End Sub