Hello all,
I have a vb.net application that I need to scrape data from.
The source code is not available to me (contractor not available to us - the application was developed several years ago)
I am writing a C# application to scrape from a particular toolStripLabel on a toolStrip (of that VB Application).
When I use Spy++ I can see the information for the ToolStrip (Handle, Caption ,Class , Style etc) - but it does not see the toolStripLabel that contains the data I need.
I am testing my concept with a console application that will parse the data (to a text file) out of a very quick VB Form that I created
(which includes a toolstrip and a toolStripLabel) - the output does not include the toolStripLabel on the toolstrip.
I am very new to using 'hWnd' and delegate to the "user32.dll" functions and most of what I have done is based on what I have seen in forums and some MSDN articles.
Is there anyway that I can dip further into the ToolStrip to get the label data
- or can anyone suggest a delegate function that I should be using?
I have included my output - as you can see the command buttons and TooStrip text are found - but not the toolStripLabel text.
Thanks for any suggestions or pointers!
My code is as follows:
foreach (Process procesInfo in Process.GetProcesses())
{
if (procesInfo.ProcessName.ToString().Contains("testToolStrip"))
{
Console.WriteLine(procesInfo.ProcessName.ToString());
Console.WriteLine("Target process found" + " " + procesInfo.ProcessName.ToString() );
foreach (ProcessThread threadInfo in procesInfo.Threads)
{
IntPtr[] windows = GetWindowHandlesForThread(threadInfo.Id);
if (windows != null && windows.Length > 0)
foreach (IntPtr hWnd in windows)
{
System.IO.StreamWriter file = new System.IO.StreamWriter(@"c:\scrapeTest.txt", true);
file.WriteLine("\twindow {0:x} text:{1} caption:{2} xx:{3}", hWnd.ToInt32(), GetText(hWnd), GetEditText(hWnd), GetEditText(hWnd));
file.Close();
}
}
}
}
It produces a textfile with the contents:
window 4f142c text:Form1 caption: xx:
window 6414e4 text:Button2 caption:Button2 xx:Button2
window 74154e text:Button1 caption:Button1 xx:Button1
window 1d1458 text:I am the toolStrip text caption:I am the toolStrip text xx:I am the toolStrip text
window 4d14a0 text:.NET-BroadcastEventWindow.4.0.0.0.2bf8098.0 caption: xx:
window 4a14ea text:M caption: xx:
window 33153c text:Default IME caption: xx:
window 27147c text:GDI+ Window caption: xx:
window 531430 text:Default IME caption: xx: