If your control has a "Handle" property you will be able to retrieve this by calling GetProperty() method against the said control.

If your control does not have a Handle property, you can return the handle by using GetForegroundWindow() function from the "user32.dll".  This function retrieves the handle of the active window.  So in your script you initially set the control active, then call GetForegroundWindow().

See example below that shows how declare your dll and call GetForegroundWindow() to retrieve the handle of the Notepad text area.  The handle will be returned to the "output" console window:-

Public Module Main

_desktop As Desktop = Agent.Desktop
 Dim WinID As Long 'Variable to contain Handle

 Public Declare Function GetForegroundWindow Lib "user32.dll" () As Long 'declaring function
 Public Sub Main()
 With _desktop.Window("Notepad")
   .Click(MouseButton.Left, New Point(125, 15), ModifierKeys.None)
  WinID = GetForegroundWindow()
  Console.WriteLine ("Window Handle =  " & WinID)
  End With
 End Sub
End Module