Hi,
Thanks for the response.
What i'm trying to do is write code to enter text in textboxes and click the buttons/menu items, etc and to check the results.
For example:
My core application stores names and address, the user is prompted to log in, enter pwd, etc.
I am writing a seperate application to:
Launch the core app
When the login screen appears
Enter "Stickle" into the user textbox (txtUserName), and "Projects" into the pwd (txtPWD), then click the cmdOk button.
Wait for 30 seconds for the application (frmMain) to appear, if this fails, to write "Failed" into a text file.
The core application is writted in VB6, I have control over the source code and can recompile it into either pcode or native.
This is for automating the testing and recording the results - it's a fairly large application and I will evolve various other scripts from login to change pwd, to add customer, etc.. you get the idea?
I have already tried adding code to my application to do this but my testing needs to be outside of the main app thread, and none of the threading i've tried actually does this (startthread or timer), and my C++ is ok, but my windows c++ is too light for com and stuff so I can't use c++ to do this.
My research so far has found:
Given a process id, i can get the active window.
given an active window (hwnd), I can use API to retrieve the hwnd of the child windows, then use WM_GetText and SendMessage to update the text in the textboxes and click the buttons.
This is ok, but I need to use WM_GetText to identify the each textbox and can't use the control name from VB, and labels don't appear in the enumchildwindows list.
so,
more research found that the control stuff is placed on the Heap for the application, and by interrogating the heap, I can get the control properties and names at runtime
I've attached all the stuff I have so far (this has been collated from an article in Experts-Exchange and various other web-searches)
The routine enumvbcontrols is the basis for all of my research and it does actually work and get's me the control names and runtime properties of a form.
However, it takes minutes to run against a large-ish application per form!!! (I think something to do with the number of controls and menus and stuff)
Google came up with a number of people having the same problem - it stems from Heap32Next being slow, and I found someone who had a solution (
http://securityxploded.com/enumheaps.php) but I can't interpet his code into VB or c#.
I have tried the HeapWalk API - which also works and gets me the heap details required (see doHeapWalk in my code) but it crashes when running against my application with memory exception.
I know this is a long post, but wanted to let you know everything i've tried.
I'd be grateful if you have any advice for me - or a completely different solution - i don't mind.
Thanks
Kieron