12-08-2009 08:01 AM
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.
Solved! Go to Solution.
12-08-2009 08:08 AM
RealBjörkis wrote:I have tried different methods without any results.
Welcome to the forum.
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.
12-08-2009 08:17 AM
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
12-08-2009 08:28 AM
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.
12-08-2009 08:30 AM
Hi , Mi last answer was for Mathan. Shubert , I will try your proposiition and see if it works, thanks!
12-08-2009 08:42 AM
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
12-08-2009 09:21 AM
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?
12-08-2009 09:27 AM
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
12-08-2009 09:42 AM
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.
12-09-2009 02:25 PM
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