03-16-2023 11:19 AM - edited 03-16-2023 11:20 AM
I am trying to use python to control a Labview application that has been compiled into an executable. I can access the VI through the following code snippet
import win32com.client
import os
#start the exe
exe_path = r'D:\PyAE with FPGA\BEPyAE.exe'
os.startfile(exe_path)
#Dispatch application
labview = win32com.client.Dispatch("BEPyAE.Application")
#get VI reference
VI = labview.getvireference(r'D:\PyAE with FPGA\BEPyAE.exe\BE_PyAE_01.vi')
This works fine. However, another labview program is also compiled within this same executable, and this is opened immediately once the first executable is run. The application is called PyScanner, and the VI name is FPGA_PyScanner_01.vi. I cannot seem to access that VI. I have tried various permutations and combinations for obtaining the labview VI reference, but nothing seems to work. I have attached a screen grab of the project so you can see how things are structured. Is there a way to access FPGA_PyScanner_01.vi ?
Solved! Go to Solution.
03-16-2023 02:31 PM
Hi Rama,
@RamaV wrote:
I have attached a screen grab of the project so you can see how things are structured. Is there a way to access FPGA_PyScanner_01.vi ?
I don't think you can access that VI: as it seems from your image it runs within the FPGA…
@RamaV wrote:
However, another labview program is also compiled within this same executable, and this is opened immediately once the first executable is run.
Usually there is only one "program" compiled into the executable. And usually a Windows executable opens a UI upon start of execution.
So I expect this "usual behaviour"…
03-17-2023 12:16 PM
Thanks Greg. I guess I didn't get the verbiage right, there are two VIs that are within the exe, and one of them launches, and on launching, immediately launches the second VI. It is this second VI I would like to control with python, is there a way I can do it?
03-17-2023 12:50 PM
Oh wait, I found the solution. It seems it works if we use the absolute paths, not the ones in the labview project view.
labview = win32com.client.Dispatch("BEPyAE.Application")
VI = labview.getvireference(r'D:\PyAE with FPGA\BEPyAE.exe\BE_PyAE_01.vi')
VI_s = labview.getvireference(r'D:\PyAE with FPGA\BEPyAE.exe\FPGA PyScanner\FPGA_PyScanner_01.vi')
This gives me the control I need.