This can be achieved with ActiveX methods and properties. In order to connect to your executable, you must Enable ActiveX server on the Advanced Page (Application Properties Dialog Box) under Build Specifications. You may also need to enable VI server settings for your project before creating your executable.
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".
import win32com.client
labview = win32com.client.Dispatch("Labview.Application")
VI = labview.getvireference(r'c:\TEMP\ctrl\ctrl.vi')
print(f'Name: {VI.Name}')
print(VI.getcontrolvalue('main'))
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\ctrl.vi')
print(f'Name: {VI.Name}')
print(VI.getcontrolvalue('main'))
Additional InformationIf your LabVIEW code includes
user interface events, consider switching to
custom events as the first ones
won't be triggered programmatically.