From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-08-2011 08:37 AM
I would like to learn more about using Win32API calls from Labview and am currently running LabView v 8.2
Are there any examples of how to control a 3rd party applications from Labview with Win32API calls?
For starters, I am specifically interested in clicking buttons, setting edit box text fields, and retrieving edit box text fields. Also I need to know what Ineed to download to use the Win32API calls.
I know there are a couple of toolboxes out there but I really would like to know how to utilize the Win32API calls from Labview so that I can use this method of interfacing Labview with other applications.
Any hel, info, or white papers on this that points me in the right direction of this is greatly appreciated.
thanks
09-08-2011 09:00 AM
You do not need to download anything to use the Windows API functions. This is done via the Call Library Function Node. There have been numerous examples posted in this forum for various Windows API functions.
Easy method: Use a third-party program that does this and has an interface that you can use from LabVIEW. A good one is Auto-It.
Hard method: Use the Call Library Function Node to call all of the required Windows API functions. This involves reading MSDN, which contains all of the documentation for the functions you want (assuming of course that you've figured out the ones you want), figuring out the way to configure the CLFN for the specific function you need, and then debugging the crashes.
Your call.
Good luck.
09-08-2011 11:00 AM
Thanks for the info.
One other question... What dll or library file do I set the Call Library function node to use?
09-08-2011 11:44 AM
That completely depends on the function that you are trying to use. MSDN has details on each function, indicating which DLL contains it. The windows-related functions should all be in user32.dll.
09-08-2011 03:42 PM
OK, so I am attempting to put together a Labview vi to set an edit box value on a 3rd party application
with SetDlgItenText.
The command syntax is:
BOOL WINAPI SetDlgItemText( __in HWND hDlg, __in int nIDDlgItem, __in LPCTSTR lpString );
I have set up this Call library function with the following parameters:
HWND - I set to type: "Instance Data Pointer"
nlDDlgItem - I set this to an unsigned 16 bit int type and have connected a numerical contant value of 1008 which happens to be the ID of the control that I wish to set.
LPCTSTR - I set this to type "string" & string format to "string handle". I then created a string constant that i connected to this node that is set to "4
When I run this I get a return value of "0" which means that this was unsuccessful and the 3rd party application edit box is left undisturbed.
I noticed that the Call library function does not contain a node for HWND and I can only guess that this may
be why it is not controlling the edit box on the 3rd party application. If this is the case, how do I specify the handle to the window of the 3rd party application?
If this is not the case, can anyone tell me what Iam doing wrong?
thanks again
09-08-2011 04:05 PM
Well, you're doing just about everything wrong, unfortunately. I told you this was the hard way....
hDlg is of type HWND, which is an unsigned integer. You can get its value from FindWindow. FindWindow wants 2 strings, the first being the class name of the window (you can set this to null) and the second being the title of the window.
nIDDlgItem is an integer. I don't know why you are using a 16-bit integer. Are you running Windows 3.1?
lpString is a of type LPCTSTR , which is a constant string. It should be passed as a C string pointer, not a string handle.
See if the attached works for you.
09-09-2011 06:19 AM
[quote]
Well, you're doing just about everything wrong, unfortunately. I told you this was the hard way....
hDlg is of type HWND, which is an unsigned integer. You can get its value from FindWindow. FindWindow wants 2 strings, the first being the class name of the window (you can set this to null) and the second being the title of the window.
nIDDlgItem is an integer. I don't know why you are using a 16-bit integer. Are you running Windows 3.1?
lpString is a of type LPCTSTR , which is a constant string. It should be passed as a C string pointer, not a string handle.
See if the attached works for you.
[/quote]
Thanks for setting me straight on this. I don't mind the "hard way" if I learn something that I can use. The third party tools, although easier to use, are just another layer that will keep me from understanding the mechanics of this and are just one more thing to have to include/support with my applications.
I would also really like to check out your example, but I only have Labview v8.2 at this time and I get an error message that your example if a newer version 9.0 vi and it won't load on my system so Iwill have to wing it with what you wrote in your response.
Thanks for taking the time to help me understand this!
09-09-2011 08:02 AM
Attached is the VI in 8.2. Note that LabVIEW 8.2 has a bug in that you cannot wire the error cluster from CLFN to CLFN. If you do so the compiler will be unable to compile the VI, resulting in a broken arrow.