Automatically taking screenshots of program window

24,571

Solution 1

I use AutoIt plus captdll.dll for all my Windows GUI automation tasks.

Example:

Run("Notepad.exe", @WindowsDir, @SW_MAXIMIZE)   ; Open NOTEPAD
Sleep(1000)
Send("Just a Test")   ; Send some text to notepad

; Save the screen to test.jpg  
$anPos = WinGetClientSize("")
$nLeft = 0
$nTop = 0
$nRight = $anPos[0]
$nBottom = $anPos[1]

$sFileName = "test.jpg"
DllCall("captdll.dll", "int:cdecl", "CaptureScreen", "str", $sFileName, "int", 85)

This way you can automate the entire screenshot capturing process:

  • start your application with Run
  • select each of your menu options with Send
  • complete each screen's data also with Send
  • capture with DllCall("captdll.dll" ....)

You can also add conditional logic, loop, etc.

Solution 2

I've tried many and the one that really stands out, in my opinion, is Adobe (formerly Macromedia) Captivate. It's atrociously expensive (~800$) but worth every penny.

Creating tutorials etc. takes minutes instead of hours.

Solution 3

If it's a webapp you can use Selenium. There is a similar tools for Visual Studio's called Test Automation FX

Solution 4

Yoiu can look into existing Windows Automation API : UI Automation, MSDN documentation

Run-Time Requirements

UI Automation is supported on the following operating systems: Windows XP, Windows Server 2003, Windows Server 2003 R2, Windows Vista, Windows 7, Windows Server 2008, and Windows Server 2008 R2.

Client applications, from simple test scripts to robust record and playback utilities, may require access to elements that are not currently instantiated, such as a file open dialog or a menu item and therefore do not exist in the UI Automation tree. These elements can only be instantiated by reproducing, or "playing back", a specific sequence of user interface (UI) actions through the use of UI Automation properties such as AutomationID, control patterns and event listeners. See Test Script Generator Sample for an example that uses Microsoft UI Automation to generate test scripts based on user interaction with the user interface (UI).

You can use AutomationIdProperty inside existing Visual Studio project.

Implementing UI Automation in a Test Application

  • Add the UI Automation References.

The UI Automation dll's necessary for UI Automation clients are listed here.

UIAutomationClient.dll provides access to the UI Automation client-side APIs.

UIAutomationClientSideProvider.dll provides the ability to automate Win32 controls. See UI Automation Support for Standard Controls.

UIAutomationTypes.dll provides access to the specific types defined in UI Automation.

  • Add the System.Windows.Automation namespace.

This namespace contains everything UI Automation clients need to use the capabilities of UI Automation except text handling.

  • Add the System.Windows.Automation.Text namespace.

This namespace contains everything a UI Automation clients need to use the capabilities of UI Automation text handling.

  • Find controls of interest

Automated test scripts locate UI Automation elements that represent controls of interest within the automation tree.

There are multiple ways to obtain UI Automation elements with code.

Query the UI using a Condition statement. This is typically where the language-neutral AutomationIdProperty is used. Note An AutomationIdProperty can be obtained using a tool such as UISpy.exe (UI Spy) that is able to itemize the UI Automation properties of a control.

Use the TreeWalker class to traverse the entire UI Automation tree or a subset thereof.

Track focus.

Use the hWnd of the control.

Use screen location, such as the location of the mouse cursor.

See Obtaining UI Automation Elements

  • Obtain Control Patterns

Control patterns expose common behaviors for functionally similar controls.

After locating the controls that require testing, automated test scripts obtain the control patterns of interest from those UI Automation elements. For example, the InvokePattern control pattern for typical button functionality or the WindowPattern control pattern for window functionality.

See UI Automation Control Patterns Overview.

  • Automate the UI

Automated test scripts can now control any UI of interest from a UI framework using the information and functionality exposed by the UI Automation control patterns.

Related Tools and Technologies

There are a number of related tools and technologies that support automated testing with UI Automation.

UISpy.exe (UI Spy) is a graphical user interface (GUI) application that can be used to gather UI Automation information for both provider and client development and debugging. UI Spy is included in the Windows Software Development Kit (SDK).

UIAutoCmd is a command-line tool with capabilities similar to UI Spy.

MSAABridge exposes UI Automation information to Active Accessibility clients. The primary goal of bridging UI Automation to Active Accessibility is to allow existing Active Accessibility clients the ability to interact with any framework that has implemented UI Automation. Security

For security information, see UI Automation Security Overview.

Solution 5

Yes. You want automated testing software, which can do all this and test your product too.

http://en.wikipedia.org/wiki/List_of_GUI_testing_tools

Share:
24,571
Srneczek
Author by

Srneczek

dunno

Updated on April 10, 2020

Comments

  • Srneczek
    Srneczek about 4 years

    I'm looking for a software that combines macro recording with screenshot taking capabilities.

    We have a software manual with a number of screenshots. When new version of software is released we need to update most of screenshots and we have to do it manually. Now we started translating manual to several languages and number of screenshots to take have increased ten fold. We'd like to automate this process.

    There will be a recorded macro or something that clicks button within our software and takes screenshots of the program window. Better yet, we can specify the name of each screenshot individually though it's less important.

    Does such a thing exist?

  • Ben
    Ben over 13 years
    A lot depends on what tools you are used to. Tools exist which can be programmed in everything from Perl, Java, C#, VB and JavaScript to Ruby. Consider AutoIt for example, as in this question: stackoverflow.com/questions/370673/…
  • Srneczek
    Srneczek over 13 years
    Ben, I'm aware of GUI testing tools. My question is not about testing though it comes close. The question is which software can walk through the Windows software and take screenshots of the program window.
  • Artur Mustafin
    Artur Mustafin over 13 years
    @Sergey Kornilov: Look into Windows Automation API