Jump to content

Recommended Posts

Hello all,

I am looking for a way to find controls on an executable LV program. 
I need this function because I want to automate a series of tests (user mouse clicks for example) on an executable LV program.

The normal tools who does it with windows objects are not able to recognize LV controls individually.

My idea is to find a way to recognize LV controls so I can interact with them individually.

If anyone knows any third party programs to do automation tests for a LV exe that would also be highly appreciated.

 

Best Regards,
Vlad

Edited by Voklaif
Link to comment

Using another LabVIEW program control values can be changed easily.  Just open a reference to the VI, get references to the controls, (usually by name), and invoke the Value (Signal) method on the control, all using VI Server.  A better solution might be to add functionality into your application to perform automated testing, which invokes a state machine.

Link to comment

Thanks for the reply hooovahh,

If I understood you correctly I need to put some code in the executable VI.

I wanted to do the task (of interacting with the executable VI) without "planting" anything in the executable, meaning - can I get the controls references of any executable VI?

Also, I did not fully understand this: 

1 hour ago, hooovahh said:

Just open a reference to the VI, get references to the controls, (usually by name), and invoke the Value (Signal) method on the control, all using VI Server.

Vlad

Link to comment

Examples like this are hard to give, since they often rely on multiple built EXEs, the right run time engine etc.  But the basics of it, is you can use the Open Application Reference to open a session to LabVIEW, or a LabVIEW built EXE, if the settings and port are enabled in the INI file for LabVIEW or your application.  Once this is open you can use the application reference to do stuff like list all VIs that are open in that application.  From there you can use the Open VI Reference, using the application reference from earlier, and the VI name (or VI Path).  Then you can use functions like the Traverse For GObjects to find objects in that VI that have the label and type you are looking for.  There is also a function in the Hidden Gems package that can find object references by name.  You can then cast these object references to their More Specific reference, and if that class type is a control you can use the property node Value Signaling event on that control reference giving it the data type associated with that control.  

Did I lose you yet?  This is why I suggested editing your program to support the functionality you want, rather than try to augment it externally.  Neither are easy, but one is more difficult than the other, and one is more susceptible to breaking if your code is updated, and your tool isn't.

Link to comment
  • 2 weeks later...
On 8/17/2016 at 8:29 PM, hooovahh said:

But the basics of it, is you can use the Open Application Reference to open a session to LabVIEW, or a LabVIEW built EXE, if the settings and port are enabled in the INI file for LabVIEW or your application.

Sorry for my delayed response.
I've tried to do what you said in the line I quoted, but I didn't manage to accomplish it.

I am attaching my attempt, if you could look into it. It's basically an executable file and another VI who tries to get a reference to that running executable.
I think this is the step that I am missing! After I could get the reference to the running executable I think I will be able to handle the rest.

Regards,
Vlad

Test VI.zip

Link to comment

Sure thing, sorry I forgot a couple of other details.  To enable VI Server access in an EXE you need to add a few lines of text to the built EXE INI file.  In your case this is the Executable.ini file in the Executable folder.  This INI gets rebuild every time a new build is made, so you will either want to edit this every time, edit it programatically using a Post Build VI, or you can actually specify the INI to use in the application builder settings under Advanced >> Use Custom Configuration File.  In this case you can add this text manually just so you can see it working.

server.tcp.enabled=True
server.tcp.access="+localhost"
server.tcp.port=3398

This enables the server, enables it for localhost access, and sets the port to 3398.  This can be any number but needs to be unique.  Then in the Open Application Reference you specify the port as 3398, and the machine as localhost.  Once you have done this, run the EXE, run your VI, and you should be able to do things like list the Exported VIs, open references to those VIs, and get references to the controls on the front panel.  Attached is a snippet back saved to 2014 that will read the Boolean Indicator value.

 

Open Reference_BD.png

Link to comment

Hello again,

After successfully controlling some controls in my executable (thanks again hooovahh), I would like to interact with the executable's Run-Time Menu.
I could not find a way to get its reference. The best I could come up with it's the RT Menus path (added a screenshot).

RT Menu path.png

My question is: Is there a way to get an executable's RT Menu reference? I would like to programatically control it.

Thanks,
Vlad 

Edited by Voklaif
Link to comment

Nope, as far as I know there is no way to programatically control this.  There are a few private methods that have "Not Implemented" in them and mention Mercury and Merlot branches.  This makes me think that at one point NI wanted this functionality, maybe for themselves but since it hasn't be finished in the several years that I've seen this private function I'd guess NI found another way to do what they wanted.

If you have the source maybe you could make some hidden controls that VI Server can interact with but the user can't.  Like if you have a File >> Exit function, just also have a hidden Exit button that can be invoked which triggers the same code execution.  Of course this might be duplicating some of the work you already have.

Another option for these menus might be keyboard simulation.  If you press Alt+F it opens the File menu, then you could press Down arrow until the desired menu is selected.

I've wanted this function off and on for a few years so I've made an idea exchange item here.

Link to comment

Thanks for the replies.

I want to try the method of key pressing but I ran into a problem.
Whenever I press keys (for example, ALT -> Right Key) programmatically, the menu that is chosen is the one of the VI that I run (and not my target running exe).

Things I've tried:
Minimizing the controlling VI.
Making the running exe FP Behavior Modal/Floating.
Making the running exe FP State Standard/Max
Making the running exe FP Frontmost (it already is, but still gave it a shot)

I can't simulate a simple way to chose the running exe, so that the keys I press programmatically will effect him.
Any way to make this happen is much appreciated :)

Vlad

Link to comment

Okay here's the solution I did that seems to work.  You need to make the window the front and focused so that the key presses go into that window.  This can be done by setting the Z order.  Using this API there is a function called Move Window To Top and you just need to give it the window title name.

http://www.ni.com/example/29935/en/

Then I used a this API for sending key presses like Alt and then arrow keys (with delays in between)

https://decibel.ni.com/content/docs/DOC-15310

  • Like 1
Link to comment
  • 2 years later...

Hi,

I am trying to pass values to the LV exe file from a vi. I have followed the steps outlined in the post below, but had no luck. The exe does not show in the list of the vi's in the memory. I have set the port no for the vi server and in the config. file to 3364 (tried other no's too). The vi. shows any labview files that are currently open except for the exe one I am looking for. 

Can anybody see what I am missing/doing wrong? I have attached the config. file as well. 

Thanks,

Ola

On 8/29/2016 at 2:15 PM, hooovahh said:

Sure thing, sorry I forgot a couple of other details.  To enable VI Server access in an EXE you need to add a few lines of text to the built EXE INI file.  In your case this is the Executable.ini file in the Executable folder.  This INI gets rebuild every time a new build is made, so you will either want to edit this every time, edit it programatically using a Post Build VI, or you can actually specify the INI to use in the application builder settings under Advanced >> Use Custom Configuration File.  In this case you can add this text manually just so you can see it working.

server.tcp.enabled=True
server.tcp.access="+localhost"
server.tcp.port=3398

This enables the server, enables it for localhost access, and sets the port to 3398.  This can be any number but needs to be unique.  Then in the Open Application Reference you specify the port as 3398, and the machine as localhost.  Once you have done this, run the EXE, run your VI, and you should be able to do things like list the Exported VIs, open references to those VIs, and get references to the controls on the front panel.  Attached is a snippet back saved to 2014 that will read the Boolean Indicator value.

 

Open Reference_BD.png

 

image.png

Pilot_Photonics.ini

Pilot.ini

Edited by Aleksandra Kaszubowska
file change
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.