Get Control Value of VI and EXE from Python

Updated Aug 5, 2019

Reported In


  • LabVIEW

Programming Language

  • Python

Issue Details

I would like to connect to a running VI or executable built from a VI and acquire front panel values using Python.
How can I do that?


To do so you can utilize the win32com and pywin32 modules in your Python code. The following code connects to a running VI specified by a path and returns the value of a control called "main".
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'c:\TEMP\ctrl\')
print(f'Name: {VI.Name}')
If you would like to connect to a built executable you have to modify the dispatch application parameter and also the path of the VI will be added as an extra layer to the reference path:
import win32com.client

labview = win32com.client.Dispatch("ctrl.Application")
VI = labview.getvireference(r'c:\TEMP\ctrl\Ctrl.exe\')

print(f'Name: {VI.Name}')

Additional Information

The solution above utilizes ActiveX. You can also use the Python Integration Toolkit for LabVIEW by Enthought for a more integrated solution between LabVIEW and Python.

In order to connect to your executable, you must Enable ActiveX server on the Advanced Page (Application Properties Dialog Box) under Build Specifications.