Example Code

Programmatically Type Text

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Software

  • LabVIEW Database Connectivity Toolkit
  • LabVIEW

Code and Documents

Attachment

Download All

Overview

This VI is designed to programmatically type a string to wherever the curser is. It uses the keyb_event function of the user32.dll to type each letter in the second for loop and creates an array of numerics in the first for loop which refer to each letter in the string. To select which letters to type, the code converts each letter into its corresponding ASCII code.

 

Description

There are currently some limitations to the code: It currently only types a few different punctuation marks as these do not translate directly from there ASCII codes to the dll commands, so cases have been added for each piece of required punctuation. It is currently not case sensitive and does not offer the functionality of using the shift key (or any other) in conjunction with another key. These limitations are there because this was all I needed for my application but it wouldn't be too hard to modify this to include the additional functionality.

 

Requirements

  • LabVIEW 2012 (or compatible)

 

Steps to Implement or Execute Code

  1. Type in a string to String control.
  2. Run the VI.

 

Additional Information or References 

VI Snippet

153.png

 

**This document has been updated to meet the current required format for the NI Code Exchange.**

 

Joel G
Applications Engineer
National Instruments UK & Ireland

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.