You could do it like this:, Use a timer and get the mouse position then get the hWnd with API Function WindowFromPoint.

ex:

Code:
Private Declare Function WindowFromPoint Lib "user32" Alias "WindowFromPoint" (ByVal xPoint As Long, ByVal yPoint As Long) As Long
Private Declare Function GetCursor Lib "user32" Alias "GetCursor" () As Long
Private Type POINTAPI
x As Long
y As Long
End Type

Private Sub Timer1_Timer()
  Dim lp As POINTAPI, value As Long
    GetCursorPos lp
      value& = WindowFromPoint(lp.x,lp.y)
        Label1.Caption = value&
End Sub