Page 1 of 1

how to get all text from the webgadget

Posted: Wed Nov 13, 2024 5:58 am
by ynkrc
some webpages content may changed after loading(js control).
so I want to get the final text through the webgadget
but the webgadget getgadgetitemtext method has no #pb_web_alltext parameter.

What should I do?

Re: how to get all text from the webgadget

Posted: Tue Nov 19, 2024 3:06 pm
by ynkrc
Problem solved, here are some key codes.

Code: Select all

  Protected *OuterHTML, Browser.IWebBrowser2 = GetWindowLongPtr_(GadgetID(WebGadget), #GWL_USERDATA)
  Protected DocumentDispatch.IDispatch, DocElement.IHTMLElement, Document3.IHTMLDocument3
  If Browser
      If Browser\get_Document(@DocumentDispatch) = #S_OK And DocumentDispatch
        If DocumentDispatch\QueryInterface(?IID_IHTMLDocument3, @Document3) = #S_OK And Document3
          If Document3\get_documentElement(@DocElement) = #S_OK And DocElement
            If DocElement\get_outerHTML(@*OuterHTML) = #S_OK;gethtml
            ....or......
            If DocElement\get_innerText(@*innertext) = #S_OK;getalltext
            
You can determine whether the web has been loaded by detecting whether there are some keywords in the text.
I hope it is useful to those who need it.

Re: how to get all text from the webgadget

Posted: Tue Nov 19, 2024 3:13 pm
by Axolotl
Thanks, but it looks like this is not executable code.
Regarding the use of GetWindowLong_()
Please see the MSDN note on that.

Note If you are retrieving a pointer or a handle, this function has been superseded by the GetWindowLongPtr function. (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit Windows.) To write code that is compatible with both 32-bit and 64-bit versions of Windows, use GetWindowLongPtr.

Re: how to get all text from the webgadget

Posted: Tue Nov 19, 2024 3:33 pm
by ynkrc
Thank you for reminding me.
Axolotl wrote: Tue Nov 19, 2024 3:13 pm
Note If you are retrieving a pointer or a handle, this function has been superseded by the GetWindowLongPtr function. (Pointers and handles are 32 bits on 32-bit Windows and 64 bits on 64-bit Windows.) To write code that is compatible with both 32-bit and 64-bit versions of Windows, use GetWindowLongPtr.