09-21-2009 01:31 PM
Hello,
I have a question about how can one application send a string, representing a barcode, to the Edit Box (or Text Box) of a second application (no info about this application ctrl's is available), that is processing all the barcodes. Also, first application must "press" an 'OK' button on the second application dialog box.
First application, that will be written in CVI, starts by enumerating top level windows, using Windows API function - EnumWindows. Enumeration will stop when the desired window caption is found. A handle for that window will also be available. I don't know how to find a handle to the Edit Box Control. There are no Child Windows of that top level window.
Any suggestion about how to implement this is realy appreciated.
Regards
Solved! Go to Solution.
09-22-2009 05:55 AM
miniMe wrote:
"There are no Child Windows of that top level window."
are you sure of that ? have you verified with Spy++ or a similar tool ? if this is the case, it means that this window does not use windows common controls.
if it were, i would have suggested sending a WM_SETTEXT message to that control, or using the SetWindowText() function in the Windows SDK.
but if it is not... it has been built using a gui framework which draws its own child window (like CVI does for example). can you find any information about the framework or compiler used to build this executable ? it may reveal some very useful informations to solve your problem.
09-22-2009 07:50 AM
Hello, I check with spy++, and it also shows there are no child windows of the top one. See attachment.
The "second application" that I use for my tests is Teststand, top window I'm looking for is "UUT Information". On this window there is a Text Box labeled "Enter UUT Serial Number", in this control I want to insert the string from the first application.
However, if I want to implement my application on a window that is not using windows common controls, what information about the framework should I look for ? Let's say I'd like to use it on a VB.NET application.
What if the window is implemented with windows common controls, will EnumChildWindows enumerate al the controls on the top level window ? Probably FindWindowEx can also be used ?!
Regards
09-22-2009 08:04 AM
I forgot to mention that "UUT Information" top window class, as reported by Spy++, is "CVIRTLVDChild285212672".
Regards
09-23-2009 08:27 AM
from the class name of your application, it seems obvious the application you want to remotely control was built using CVI. i am not aware of any way to control such a window remotely, nor do i know any way of enumerating child windows. this is so because CVI redefines everything and draws its own controls instead of using the native functions from the window manager. it would be nice if someone at NI could answer this thread.
(off topic: that's where a gui framework like the one coming with CVI shows its limitations. could the same person at NI answer those other questions: how does a CVI application behave under text-to-speech ? how does the accessibility features of windows interact with a CVI application ?)
09-23-2009 11:24 AM
@dummy_decoy: not sure if this answers your question about accessibility, but I tested that a CVI application responds correctly when using the On screen keyboard (OSK) utility, both on parent and child panels.
09-23-2009 03:07 PM
on-screen keyboard is quite a different beast, since it injects standard keyboard events at a very low level (MouseKeys, a quite unknown feature of windows will work as well (Alt+Shift+NunLock)).
but i would like to see the result with the screen reader or a high-contrast profile for vision impaired people (in fact, i don't have a CVI based application at hand to test, and i don't have a sound card at work)
09-23-2009 04:35 PM
Hello All -
@miniMe - I couldn't help but notice from the information that the window you are looking to interact with is part of the standard TestStand installation (modelsupport2), for which the source code is readily available. While modifying modelsupport2 is not for the faint of heart, your task is specific enough that I was able accomplish it with only a handful of lines of code (be sure to copy the modelsupport2 files to the public location before making changes). The important components are below:
The application that is going to be sending the UUT number can send the WM_COPYDATA message to the TestStand application. Using this message is pretty straightforward, and allows you to pass data (such as a UUT string) across process boundaries. Here is the relevant piece from my small test app that sent the message:
The receiving end of this is also pretty straight forward. In the modelsupport2 project in CVI, you just need to make a couple modifications to the uutdlg.c module. Specifically, you need to use InstallWinMsgCallback in the function DisplayUUTInformationDialog to receive the WM_COPYDATA message. It should look pretty similar to this:
Finally, again in uutdlg.c, you need to define the implementation for the WinMsgCallback. My implementation looked like this:
Also - don't forget to call RemoveWinMsgCallback. Once you've made these changes, you just need to rebuild modelsupport2.dll, and the messaging should work as expected.
Feel free to let me know if you have any questions about this. I left out some of the TestStand specifics assuming you may know about the public directories etc. Let me know if you're unsure about any of this.
@dummy_decoy - I don't have a complete answer to your question, but want to point out that one thing that must be remembered about CVI is that it was and is intended to be multi-platform. This is the primary reason our controls and panels don't always play nice with the Win32 api. We've done what we can to make sure there are workarounds for users who need this functionality - as I hope my solution demonstrates - and are always open to suggestions on how we can improve interoperability with the Win32 platform.
I personally don't have any experience with the other specific aspects of your question, and so am not comfortable making any statements about them at the moment.
NickB
National Instruments
09-24-2009 03:58 AM