It's almost the same as what I built a couple of weeks ago for a serie of test where I had to test if correct screens are opening. If another screen was opening I called this function.
Maybe some things to consider or tips for other people:
- To prevent that images will be overwritten, I gave them a unique name, so that a script can be ran over and over again and when it creates a screenshot it saves it as a unique image.I used the get_time() function to get a unique number to give the screenshot a name.
- I also made a message in the log that tells that a screenshot has been made and that it was saved with that unique number so that it could be found back easely.
If a person does a lot of screen capture they might want to look into some command line screen capture utilities that can capture in smaller file sizes...like gif and jpeg.
I use Snagit for a lot of things. It has a regular interface, command line usage (simple) and COM ...The COM interface is well documented and can do some really cool things like autoscroll windows and add watermarks in addition to the basic capture of windows , regions and screens. A person could easily extend the command line usage to their own needs using vbscript and COM to make it super easy to call from WinRunner.
I don't work for Techsmith, but I really like Snagit.
I implemented your function, firstPerson, but I'm having trouble synchronizing it with the correct window. The problem arises when it tries to paste the captured image. I've added various lines of code to try to make sure that the correct window is (a) displayed and (b) in focus, but it's still flaky -- sometimes it works (typically the first time), sometimes it redsiplays the AUT window and starts applying its keystokes to that. Any suggestions?
Also a comment - your variable "SNAPSHOP" needs to be defined as "static." "auto" will refresh each time the function is invoked, and it will always create a "snapshop1.bmp" file.