This documentation is archived and is not being maintained.

ValuePattern Insert Text Sample

This sample demonstrates how to use both Microsoft UI Automation and unmanaged methods to input text into standard Win32 text controls. The target text controls are a single-line text box, a multi-line text box and a rich text box.

Since the TextPattern control pattern does not support the setting of text values in a control, the Microsoft UI Automation sample code shows how to use either the ValuePattern control pattern or standard keyboard input to simulate text input depending on the target control type.

The sample defines two applications, a target and a client that operates against the target application.

NoteNote:

The target application, InsertTextTarget.exe, should be automatically copied to the InsertText client folder when you build the sample and is started manually from the client. You may have to manually copy this file to the bin/debug folder of the client application if you receive an error stating that the file cannot be found.

This sample demonstrates a specific feature of the Windows Presentation Foundation (WPF) and, consequently, does not follow application development best practices. For comprehensive coverage of Windows Presentation Foundation (WPF) and Microsoft .NET Framework application development best practices, refer to the following as appropriate:

Accessibility - Accessibility Best Practices

Security - WPF Security

Localization - WPF Globalization and Localization Overview

Download sample

Building the Sample

  • Install the Windows Software Development Kit (SDK) and open its build environment command window. On the Start menu, point to All Programs, Microsoft Windows SDK, and then click CMD Shell.

  • Download the sample, usually from the software development kit (SDK) documentation, to your hard disk drive.

  • To build the sample from the build environment command window, go to the source directory of the sample. At the command prompt, type MSBUILD.

  • To build the sample in Microsoft Visual Studio 2005, load the sample solution or project file and then press CTRL+SHIFT+B.

Running the Sample

  • To run the compiled sample from the build environment command window, execute the .exe file in the Bin\Debug or Bin\Release folder contained under the sample source code folder.

  • To run the compiled sample with debugging in Visual Studio 2005, press F5.

Remarks

Controls that support the TextPattern control pattern do not support the ValuePattern control pattern. Since TextPattern does not support text input, it must be simulated using one of the methods demonstrated in this sample.

See Also

Show: