Example Code

Simulate Mouse Click on a LabVIEW control

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

    Operating System

  • Windows

Code and Documents

Attachment

Description

It's possible to programmatically control the mouse using LabVIEW to click at discrete points on the screen using the LabVIEW Call Library Function Node, and use it to call functions from Windows's user32.dll. Relying on Windows functions like SetCursorPos and Mouse_event, you can simulate a mouse click at a given position on screen.

  

How to Use

ButtonExample.zip contains two VIs showing how to simulate a mouse click on a specific button by creating a reference to a control and using property nodes to extract the coordinates of that control.

 

Related Links

Eric V
National Instruments
Applications Engineer
Certified LabVIEW Associate Developer


"I'm a Ramblin' Wreck from Georgia Tech and a helluva (NI Applications) Engineer!"

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

Contributors