LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Select Control Label with VI Server/Scripting

Solved!
Go to solution

I am trying to flush out my scripting code - and one of the functions that I have made automatic is pulling the focus from newly dropped controls/indicators LABEL on the FP  - I want to be able to select the text of the Label - and I thought it was possible with VI Server Label.Selection.  I am using another VI to take the VI Ref of the VI I am monitoring to get the last placed Control on the FP using the Traverse Scripting function - that part is working great.

 

Label.Selection is not working, even when I immediately set KeyFocus= TRUE before the Label.Selection property.  I have even inserted a VIFrontPanel.IsForemost setting it TRUE for the target VI before requesting the KeyFocus for the control...

 

I have verified that the target VI is IDLE by reading the state of the VI.

 

GOAL: I am trying to mimic the selection of the entire label that happens when you drop a new control.

 

Any insight would be appreciated.  I have posted on the Scripting Board - but not gotten any response.

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 1 of 8
(3,378 Views)
Solution
Accepted by topic author RVallieu

On my Windows machine I would probably resort to a little mouse function trickery using user32.dll.

 

Here I simply select the first control, put the cursor in the center of the label and fake a double click.  Then I move the cursor to the bottom right.

 

SelectLabel.png

Message 2 of 8
(3,362 Views)

Great, I will try that - maybe I will just fake the triple click that selects the whole label and see if that works.

 

Thanks for the suggestion!  Other VI Server functions just were not getting me there - must be something weird with the KetFocus, as others have noted in the past that it does not work in some instances.

 

I will report back if it works out for me.

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
Message 3 of 8
(3,340 Views)

Darin - Brilliant!

 

Modifying the code to use a triple click worked like a charm, can cut out the functions after then For Loop

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
Message 4 of 8
(3,335 Views)

Now I am wondering about how to convert BD coordinates to screen coordinates to adapt the same code for if the BD was the activated screen originally.  The same nice functions do not exist for converting BD locations to Screen Coordinates that I am aware.

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 5 of 8
(3,323 Views)

There may be a better way, but I usually do this.  The constant offset works for me, you may need to double check, and you may want to verify that you will be clicking inside the window (ie. the selected object may be off screen).

 

DoubleClickBDObject.png

Message 6 of 8
(3,313 Views)

You are a mouse position manipulating madman - I love it.

 

I will double check - as the label.selection function again does not work even when I feed it the ControlTerminal reference output from my BD Traverse.  Very disappointed in this scripting property - would be so elegant if it worked as touted in the LabVIEW Help.

 

I can easily use the BD ControlTerminal Traverse, then use the output ref and get the GObject  REF I need, change to more specific class to ControlTerminal, then use the CtlTerm property of Label.TotalRect to replace the Gobj TotalRect to make sure I am only clicking on the Control Terminal's owned label.  The object will not be off the screen in this instance since I am writing the code to detect when the object is created on the BD as the BD is activated.  If it was the FP that was activated then the previously created code you helped me with will be the subVI called.

 

 GetBDLabelPosition.png

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 7 of 8
(3,306 Views)

Combining with your mouse positioning and changing from double click to triple click did the trick.  Selects the Control Terminal Label - thanks!

Ryan Vallieu CLA, CLED
Senior Systems Analyst II
NASA Ames Research Center
0 Kudos
Message 8 of 8
(3,295 Views)