Private Declare Function GetActiveWindow Lib "user32" () As Long
Private Sub Form_Load()
Timer1.Interval = 100
End Sub
Private Sub Timer1_Timer()
If GetActiveWindow() = Me.hWnd Then
Me.Caption = "在"
Else
Me.Caption = "不在"
End If
End Sub