LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

controlling a 3rd party application from Labview with Win32API calls

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

 

0 Kudos
Message 1 of 8
(1,689 Views)

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.  Smiley Wink

0 Kudos
Message 2 of 8
(1,687 Views)


Thanks for the info.

 

One other question... What dll or library file do I set the Call Library function node to use?

0 Kudos
Message 3 of 8
(1,677 Views)

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.

Message 4 of 8
(1,669 Views)

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

 

 

 

 


 

0 Kudos
Message 5 of 8
(1,660 Views)

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.

0 Kudos
Message 6 of 8
(1,656 Views)

[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!

 

0 Kudos
Message 7 of 8
(1,628 Views)

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.

0 Kudos
Message 8 of 8
(1,622 Views)