LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get VI name and path where mouse is programatically from another VI

Solved!
Go to solution

Hi, this is my first question here.

 

I am trying to create a permanent running, ObtainInfo.vi, in LV 7.1 that automatically gets ínfo from other running VI:s. I would like to obtain info from the other VI:s when the mouse is being clicked over there. Information could be the other VI:s name and/or reference. I have tried different methods without any results.

 

 

 

0 Kudos
Message 1 of 11
(3,202 Views)

RealBjörkis wrote:

I have tried different methods without any results.


Welcome to the forum. Smiley Happy

 

What are the things you have tried? Where you stuck up? Post what you have did so far. This will help us to help you better.

0 Kudos
Message 2 of 11
(3,200 Views)

You would need a polling of the 'All VIs in Memory' property of the Application. (you could alternatively use the undocumented and unsupported hooks for Open and New).

Then feed the array of vi references in a register for event node and select Mouse Down or whatever.

In the event structure you can select this dynamically registered event and use the VI Refnum to obtain things like the name...

 

Felix 

0 Kudos
Message 3 of 11
(3,193 Views)

Thanks!

 

I have investigated the possibility of obtaining info about the other VI through the event structure and mouse coordinates but there doesnt seem to be a way. It is only possible to get a reference through the event structure only for the VI where the event structure is placed. There is a Property:Application: All VI:s in memory, but no one that shows a "Active" VI, where the mouse is being hovered or used.

0 Kudos
Message 4 of 11
(3,188 Views)

Hi , Mi last answer was for Mathan. Shubert , I will try your proposiition and see if it works, thanks!

0 Kudos
Message 5 of 11
(3,187 Views)

When you select event 'Mouse Down' on the event structure, you register for that event on the vi you placed the structure. If you use dynamic registration, you can register for the VI-Events of other VIs as well (this is under dynamic events). It even works with arrays of references.

You do not need to get the acitve vi, as only the active vi will fire the event.

 

Felix 

0 Kudos
Message 6 of 11
(3,180 Views)

Hi Felix,

 

I managed to use your proposed method with the event structure with a handpicked VI reference, but how do I get the references from the Property node? I suppose I will have to search in a specific folder for every single VI delivered by "All VI:s in Memory" array, in able to get all references that I need to feed the Register for Events node? Or is there a simplier way?

 

 

0 Kudos
Message 7 of 11
(3,166 Views)
Solution
Accepted by topic author RealBjörkis

I gave it a try myself. The screenshot is attached. The problems unsolved are some errors I get when I used all VIs, the execution state property is the workaround for this. You certainly also want to have it for VIs that are Running (not top-level).

 

 

Felix 

Message 8 of 11
(3,161 Views)

Hi Felix and thanks for code. I will adapt my code according to yours and try it out. I also didnt realize that Open VI reference accepted the process name. I thougt I had to feed it with the complete path to the VI. I tried to attach a JPG image but it resulted in an error. Perhaps only PNG:s are accepted like the one you attached.

 

 

0 Kudos
Message 9 of 11
(3,151 Views)

There is one bug in my code: the shift register holding the references is not initialized.

 

When upgrading to more recent LV versions:

* the Close Ref at the end will work on arrays, so no loop around is required.

* there are several Application Instances, so the App.AllVIs will only return the VIs of the same project

 

Felix

0 Kudos
Message 10 of 11
(3,117 Views)