To capture a bitmap image of an object or window from within the script, use the CaptureBitmap method.
Object.CaptureBitmap FileName, [OverrideExisting]
**FileName T**he full path of the (.png/.bmp) image to save. If you specify a relative path, the path is added to the test report path.
**OverrideExisting** A boolean value indicating whether the captured image should be overwritten if the image file already exists in the test results folder. (Default: False)
Example:
Dialog(''Login'').WinEdit(''Agent Name:'').Set ''mercury''
' Capturing a bitmap of the entire window
Dialog(''Login'').CaptureBitmap(''D:\Temp\Bitmap.bmp'')
' Capturing a bitmap of the Agent Name edit field
Dialog(''Login'').WinEdit(''Agent Name:'').CaptureBitmap(''D:\Temp\Bitmap2.bmp'')
After running the above code inside QTP or in a function library associated, you would find two bitmap images in the D:\Temp directory. Bitmap.bmp will obtain the screenshot of the entire Login window. Bitmap2.bmp contains a screenshot of the Agent Name edit field.