Click here to Skip to main content
15,993,835 members
Please Sign up or sign in to vote.
3.33/5 (3 votes)
See more:
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:

C#
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:
Posted
Updated 5-Jul-12 4:56am
v3

Why dont you use CFF explorer to search the content of toolstriplabel.

I recreated your issue and saw that exe has got the toolstriplabel text value at
(In CFF Explorer)
.NET Directory->MetaData streams->#US


There you'll see toolstriplabel1 and then the label text in ascii pane....
 
Share this answer
 
There is only one way which would not endanger your business: admit that the company lost the work and payed money for nothing and implement some healthy code ownership practices. As to the "source code is not available to" you, it should never be used, and a new one should be created.

I would imaging that using the program which you cannot support could get more resources than writing a new program, because I know this from my experience.

I'm absolutely serious: using the program which you cannot support is wasteful and, most importantly, very dangerous. Somebody made a big mistake and lost the code, so this person should take the responsibility for the failure.

Sorry if you think this does not help you. Think of it this way: I'm just trying to help you to avoid making things worse. The more successful your "screen scraping", the more harm to your company. If your company organization and people are not capable to fix this situation through better management decisions, I don't want to discourage you, but you should realize that the company goes nowhere, and the troubles could come soon; so I would seriously advise to look for alternative job. Yes, seriously.

—SA
 
Share this answer
 
v2
I wouldn't waste my time on this. Like SAK said, even using that app is a dangerous move, let alone scraping from it.

First, is this app COMPLETELY tested?? Are there any bugs? Is there any chance of new features or bugs fixes being applied?? Nope!

No matter what happens, you're going to have to rewrite this beast from scratch, thereby making your scraping app useless since, while you're at it, you may as well put in features that can export data through either files or some remotable interface.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 5-Jul-12 16:31pm    
It looks like we are agree on that; my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900