I am automating tests of a GUI application similar to calculator. I am using Java and [AutoIt](https://www.autoitscript.com/site/autoit/) for implementing the test cases. I need to take screenshot on failure. 

I have tried taking screenshot using BufferedImage, but it takes the screenshot of the complete page. I need to take the screenshot of the application excluding the background. For Ex:- like taking snapshot using WebDriver. Is is possible to achieve this?