| || |
- 1 Post By NoUse4aName
Getting all text on a Browser page
Is there a way to get all of the text on a browser into a single string?
Something such as:
What I am trying to do is find out if a string of text appears? Also how many times it appears.
I tried .object.documentElement.innerText mentioned in the article that you included. It returns text that looks like view source code.
I saw this on the MicroSoft site regarding GETWINDOWTEXT in an API. Do you know if it would work and what the syntax would be.
I probably need to load the win32 library first. I have to look online for that code. I don't have it handy.
Then I don't know how to use the Call to GETWINDOWTEXT.
I will do some google searching.
Has anyone gone a similar route to get all text in browser? It's not working for me.
Extern.Declare micHwnd, "FindWindowEx", "user32.dll", "FindWindowExA", micHwnd, micHwnd, micString, micString
Extern.Declare micLong, "PostMessage", "user32.dll", "PostMessageA", micHwnd, micLong, micLong, micLong
Extern.Declare micLong, "GetWindowText", "user32.dll", "GetWindowTextA", micHwnd, micString + micByRef, micLong
Hwnd = Browser("Browser").GetROProperty("HWND") ' Gives a line of text regarding the Browser window. Not the whole thing.
Hwnd = B().P().GetROProperty("hwnd") 'Gives no return in string.
'Hwnd = extern.FindWindowEx(0,0, vbNullString, "MIcrosoft Internet Explorer")
If Hwnd <> 0 then
Extern.GetWindowText Hwnd,staticText, 256
Documentation on that getwindowtext method doesn't seem like it would work.
"Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However, GetWindowText cannot retrieve the text of a control in another application."
Getting the source code is probably the approach I would take.
Last edited by NoUse4aName; 05-01-2015 at 06:33 AM.
That's what it did. It returned the title bar.
I need to know how many matches there are of a string on the page. Often view source code contains the string many more times than it really shows on the screen.
Any idea on how to work with this?
I'm leaning toward automating communication using CTRL + F on the window. It gives the number of occurrances of a string on the Browser.
I wish that I could get to that code programatically. Is there a known way to call the code that IE uses internally?