how to get text from IE

Apr 27, 2011 at 9:04am
hi all
i am trying following code to get text from Internet Explorer but it fails

how ever same code works for notepad. can any one suggest how to get text from IE

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

if(strcmp(lpClassName,"Internet Explorer_Server") == 0)
	{
		cout<<lpClassName<<endl;
		cout<<hwnd<<endl;
		
		std::string text;
		WPARAM length = SendMessage( hwnd, WM_GETTEXTLENGTH, 0, 0 );
		if( length > 0 )
		{
			char *buffy = new char [length+1];
			LRESULT got = SendMessage( hwnd, WM_GETTEXT, length+1, (LPARAM)buffy );
			if( (LRESULT)length == got )
			{
				text = buffy;
				cout<<text<<endl;
			}
			delete [] buffy;
		}
	}
Apr 27, 2011 at 10:32am

IE is not a text window and this function will fail. It will only get the text from a window which is a edit or rich edit control.
Apr 27, 2011 at 11:22am
thanks for reply.

but is there any other way to get text from IE?
Apr 27, 2011 at 6:26pm
You're thinking in the wrong direction, it happens to all of us from time to time. IE is an interface used to interpret text from a source, usually one on the internet. Assuming it's HTML to keep this simple, it is sent to your system as plain text instructions. The images, sounds and interfaces that you see and use are all created or fetched by your workstation using IE and rendered into what you see based on those instructions.

If what you want is the text from a website, then you need to have something to connect to the site and pull data from it. So a good place to start would be the WinSock2 API.
Last edited on Apr 27, 2011 at 6:29pm
May 1, 2011 at 9:55pm
Use IE COM interfaces
Topic archived. No new replies allowed.