Automating Runtime Screen Captures Across the WinCC Picture Tree in SIMATIC PCS 7

Automating Runtime Screen Captures Across the WinCC Picture Tree in SIMATIC PCS 7

To automatically capture and save all operator runtime graphics (.pdl) across the WinCC Picture Tree into individual image files (e.g., BMP, PNG, or PDF) without manually navigating each screen and executing print-screen commands, engineers can deploy an automated picture traversal script in WinCC OS. By writing an ANSI-C or VBScript function that reads the Picture Tree hierarchy from the internal '@PicTree' configuration data, the script programmatically opens each picture in the background, invokes the Windows GDI screen-capture API or the native WinCC hardcopy function ('WinExec("PRTSCR.EXE ...")'), and exports the image with a unique filename derived from the picture title.

Table of Contents

Engineering Use Cases for Automated Screen Archiving

In industrial distributed control systems, generating comprehensive visual documentation of all human-machine interface (HMI) screens is a mandatory compliance requirement for:
- Standard Operating Procedure (SOP) manuals
- Factory Acceptance Testing (FAT) documentation
- Validation Master Plans in pharmaceutical plants (FDA 21 CFR Part 11)
- Operator training manuals and disaster recovery binders

In large PCS 7 facilities with 100 to 500 graphic screens (.pdl), manually opening each graphic, pressing PrintScreen, opening an image editor, pasting, and saving with a unique name requires dozens of engineering hours. Automating this process via a runtime script eliminates manual effort and guarantees standardized naming.

Accessing the Picture Tree Hierarchy Programmatically

SIMATIC PCS 7 organizes runtime graphics into a structured tree managed by the Split Screen Manager and Picture Tree Manager:
- Configuration Data: Stored in internal binary files (*.ptd) and internal WinCC tags.
- The area buttons (top navigation bar) and sub-area buttons (overview/detail screens) correspond to specific .pdl filenames.
- Using WinCC Open Architecture or standard VBScript FileSystemObject, an automated script can scan the project's GraCS directory or query the Picture Tree configuration to extract a complete list of active process pictures.

Method 1: Traversal Script with Automated PRTSCR Execution

WinCC provides a native background screen print utility: PRTSCR.EXE located in C:\Program Files (x86)\Siemens\WinCC\bin\:
- In standard operation, calling PRTSCR.EXE sends the active screen to the default Windows printer.
- By configuring the Windows default printer as a Virtual PDF Printer (such as Microsoft Print to PDF or Bullzip PDF Printer) configured for Silent Auto-Save, each print command automatically generates a timestamped file without displaying save dialogs.
- The WinCC script cycles through the picture list:
1. Calls SetPictureName() or OpenPicture() to bring the picture into the main working container (@1001).
2. Executes a 500 ms pause to allow dynamic tag connections and faceplates to render.
3. Executes WinExec("PRTSCR.EXE -f", SW_HIDE).
4. Advances to the next picture in the array.

Method 2: Windows GDI API Capture to Image Files (C-Script)

For a fully self-contained solution that exports directly to .bmp or .png files without requiring a virtual printer:
- In WinCC Graphics Designer, implement an ANSI-C script utilizing standard Windows GDI libraries (user32.dll and gdi32.dll):
- GetDesktopWindow(): Acquires the desktop handle.
- GetWindowDC(): Obtains the device context.
- CreateCompatibleDC() and CreateCompatibleBitmap(): Prepares memory buffers matching screen resolution.
- BitBlt(): Performs high-speed raster transfer of the pixels from screen memory into the bitmap buffer.
- Saves the bitmap buffer to a designated path: D:\HMI_Exports\<Area>_<PictureName>.bmp.

Comparative Automation Scripting Approaches in WinCC

The table below compares methods for bulk screen capture in SIMATIC PCS 7:

MethodOutput FormatDependenciesExecution SpeedSetup ComplexityManual PrintScreenClipboard / PNGManual laborExtremely Slow (Hours)NonePRTSCR + Silent PDF PrinterPDF / Multi-pageVirtual Printer DriverFast (~2 sec per picture)Low (Standard VBS script)Windows GDI C-ScriptBMP / PNGNative Windows DLLsVery Fast (< 1 sec per picture)Moderate (Advanced C-code)WebNavigator View PublisherStatic HTML / PNGWebNavigator OptionModerate (Export folder)Low (Native tool)

Step-by-Step Implementation Procedure

To implement automated screen capturing using VBScript and a silent virtual printer:

Step 1: Configure Silent Virtual Printer

  1. Install an automated virtual printer (e.g., Bullzip PDF Printer or PDFCreator).
  2. Configure printer settings:
    - Output Path: D:\ScreenCaptures\<title>.pdf
    - Dialogs: Never display save dialogs.

Step 2: Create Traversal VBS Script

  1. In WinCC Explorer, open Global Script > VBScript Editor.
  2. Create a new Project Function CaptureAllScreens():
    ```vbscript
    Sub CaptureAllScreens()
    Dim fso, folder, file, shell, picName
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set shell = CreateObject("WScript.Shell")
    Set folder = fso.GetFolder(HMIRuntime.ActiveProject.Path & "\GraCS")

    For Each file In folder.Files
    If LCase(fso.GetExtensionName(file.Name)) = "pdl" And Left(file.Name, 1) <> "@" Then
    picName = fso.GetBaseName(file.Name)
    ' Load picture into working container
    HMIRuntime.Screens("@Screen").ScreenItems("@1001").PictureName = file.Name
    HMIRuntime.Trace "Capturing: " & picName & vbCrLf
    ' Allow tags to refresh
    shell.Run "cmd /c ping 127.0.0.1 -n 2 > nul", 0, True
    ' Invoke printscreen utility
    shell.Run "PRTSCR.EXE -f", 0, True
    End If
    Next
    End Sub
    ```

Step 3: Attach Script to Engineering Button

  1. In Graphics Designer, place a button on an authorized maintenance screen.
  2. Under button Events > Mouse Click, call CaptureAllScreens().
  3. Activate runtime and click the button; observe automated screen cycling and file creation.

Verification

To confirm that screen captures completed successfully:
1. Target Directory Inspection: Open D:\ScreenCaptures\; verify that every non-system .pdl picture exists as a corresponding image file.
2. Visual Quality Audit: Inspect generated images; confirm that process graphics, dynamic bar graphs, and block icons render with valid colors and text without clipping.
3. Runtime Stability Check: Verify that WinCC runtime remains fully responsive and operational during script execution.

Limitations and Operational Precautions

Engineering teams must observe the following precautions:
- Automated screen cycling switches visible pictures rapidly; never execute this script on a live production console actively controlling hazardous operations.
- System pictures beginning with @ (such as @overview.pdl, @alarm.pdl) should be filtered out to prevent breaking the active split-screen navigation layout.
- Always validate final license quantities and MLFBs against the applicable Siemens catalog and authorized distributor quotation when procuring WinCC options.

Engineer FAQ

Can this script run while WinCC runtime is deactivated?

No. WinCC runtime must be active so that graphic objects, dynamic tag bindings, and faceplate ActiveX controls can execute and render live process values.

How do I avoid capturing popups or alarm banners during traversal?

The script can temporarily hide alarm windows or faceplate containers by setting their Visible property to FALSE prior to invoking the screen capture.

Can I export screens directly to Microsoft Word?

Yes. Using VBScript Automation, you can instantiate Word.Application and insert each captured image sequentially into a formatted Word document.

Technical References

Related Articles

Related Tags

  • WinCC Runtime
  • Screen Capture
  • VBScript
  • Picture Tree
  • Documentation
6 respuestas