LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

get text status bar of another software window (not a VI) using user32.dll or other dll with call library function

Hi,

I m trying to get the text of the status bar of the window of a program (not a VI) which controls an equipment.

111.png

I though that the best solution was to use user32.dll and LVWUtil32.dll functions as suggested in

https://forums.ni.com/t5/Example-Code/Windows-API-Function-Utilities-32-bit-for-LabVIEW/ta-p/3996462

 

I managed to find the main window of my equipment interface with the FindWindow function of the user32.dll. Then, using the user32.dll:GetWindow with argument 5 and 2, I manage to get the handle of the children windows including the status bar of the equipment interface window.

Then I tried to use the user32.dll:GetWindowTextLengthA and user32.dll:GetWindowTextA to read the text of this status bar which is (apparently) considered as a window.

Problem: only empty string as results.

I could not find any function relative to "status bar" in the user32.dll or LVWUtil32.dll labview examples or in the user32.dll documentation.

I believe what I am trying to do is not that hard, I am just missing the right function is the user32.dll or other dll to complete this rather simple task (I guess).

222.png

It s the first time I am using call external library with DLLs, and it's actually quite hard to figure out the right arguments to place in the prototype of the function... so I tried to find already made examples in LabVIEW and copy/pasted the call library parts.

 

Thanks for the help.

 

Regards,

 

Hicham

0 Kudos
Message 1 of 11
(5,959 Views)

Often to make these call library node functions work with strings you need to pass in a string constant with enough characters to contain the output. 

 

So pass a string constant of generous length into the GetWindowTextA input.

0 Kudos
Message 2 of 11
(5,945 Views)

I have tried with a string of 600 signs as input but I get the exact same string as output...

FYI: I m using LabVIEW 2017 on a win10 64bits computer

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

Have you wired up the error in/out terminals on all of those nodes to make sure they're not returning errors silently that you're missing?

0 Kudos
Message 4 of 11
(5,924 Views)

that s good point.

But no error

0 Kudos
Message 5 of 11
(5,922 Views)

You could try downloading AutoIT.  It's a free program that's mostly a wrapper for user32.dll (both through a scripting language and a COM extension), and has a fun utility called "AutoIt Window Info" where you can get info on any open window and all objects inside those windows.  

 

I've used it before to do things in LabVIEW and it's much easier than using raw DLL calls.

0 Kudos
Message 6 of 11
(5,905 Views)

Yep, that's also a solution I found on previous posts... It seems to work fine. I will go for AutoIT if no ones gives me other alternative using directly the user32.dll.

 

Thank you Kyle97330

 

But still open for more solutions.

0 Kudos
Message 7 of 11
(5,902 Views)

Most likely your status bar child window is the entire status bar and then there are child windows inside the child window which correspond to the individual text elements in the status bar.

 

Also, GetWindowTextA() returns the text in the title bar of the Window and since your status bar nor the text controls inside it contain a title it's not surprising that you get an empty string back.

 

If the text control inside the status bar is a standard Windows text widget, then you would have to send it a message to retrieve the text string displayed inside the control.

https://msdn.microsoft.com/en-us/library/windows/desktop/bb760767(v=vs.85).aspx

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 8 of 11
(5,892 Views)

Hi Hicham,
my name is Peter. I have a questing regarding one of the dll functions you are using. It is the one used to terminate the while loop. It would be great if you can tell me the names of the dll file and function!

So long,
Peter

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

GetWindowText() returns the window title. Since your control is a an embedded child window without a title bar, its title is usually never set or may be some text that is definitely not what you want.

 

Doing what you try to do is wrought with problems. Basically it is probably a simple Windows text control but to be sure you would need to retrieve the class name with GetClassInfo() to verify that it is indeed the type of child class you expect and then send it a message to return you the current value. 

 

SendMessage(handle, WM_GETTEXT, length, lpStrPtr);

 


I have a questing regarding one of the dll functions you are using. It is the one used to terminate the while loop. It would be great if you can tell me the names of the dll file and function!

I would go on a wild guess that it is actually the IsWindow() function.

Rolf Kalbermatter  My Blog
DEMO, Electronic and Mechanical Support department, room 36.LB00.390
0 Kudos
Message 10 of 11
(3,332 Views)