08-24-2017
01:04 PM
- last edited on
06-24-2025
02:36 PM
by
Content Cleaner
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.
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).
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
08-24-2017 01:27 PM
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.
08-24-2017 01:39 PM - edited 08-24-2017 01:41 PM
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
08-24-2017 02:03 PM
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?
08-24-2017 02:05 PM
that s good point.
But no error
08-24-2017 03:20 PM
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.
08-24-2017 03:29 PM
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.
08-24-2017 04:44 PM
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
06-21-2022 04:06 AM
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
06-21-2022 04:25 AM - edited 06-21-2022 04:30 AM
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.