Page 1 of 1

Text of INPUT elements in webgadget

Posted: Wed May 13, 2009 2:33 pm
by Hroudtwolf
Hi,

I made a function which returns the text of input elements in webgadget.
Here is my result.

Have fun.

Regards
Wolf

PS: Enter a text in the keywords-field and press enter-key.

Code: Select all

 ; 2009 Hroudtwolf
; PureBasic-Lounge.com
; Windows
; PureBasic 4.x

Procedure.s GetElementText ( idWebGadget.i , sKey.s )
   Protected WebBrowser    .IWebBrowser2 = GetWindowLongPtr_( GadgetID ( idWebGadget ) , #GWL_USERDATA )
   Protected Dispatch      .iDispatch
   Protected Document      .IHTMLDocument3
   Protected Element       .IHTMLElement
   Protected InputElement  .IHTMLInputElement
   Protected bstrValue     .i
   Protected sValue        .s
 
   If Not ( WebBrowser\get_Document( @ Dispatch ) = #S_OK )
      Dispatch\Release() 
      ProcedureReturn ""
   EndIf
   If Not ( Dispatch\QueryInterface( ? IID_IHTMLDocument3 , @ Document ) = #S_OK )
      Document\Release()   
      Dispatch\Release()   
      ProcedureReturn ""
   EndIf
   If Not ( Document\getElementById( sKey , @ Element ) = #S_OK And Element )
      Document\Release()   
      Dispatch\Release()   
      ProcedureReturn ""
   EndIf
   If Not ( Element\QueryInterface( ? IID_IHTMLInputElement , @ InputElement ) = #S_OK)
      Element\Release()   
      Document\Release()   
      Dispatch\Release()   
      ProcedureReturn ""
   EndIf
   If Not ( InputElement\get_Value( @ bstrValue ) = #S_OK )
      Element\Release()   
      Document\Release()   
      Dispatch\Release()   
      ProcedureReturn ""
   EndIf
   
   InputElement\Release()   
   Element\Release()   
   Document\Release()   
   Dispatch\Release()   
   
   If Not bstrValue 
      ProcedureReturn ""
   EndIf 
     
   sValue = PeekS ( bstrValue , #PB_Any , #PB_Unicode )
   SysFreeString_( bstrValue )
         
   ProcedureReturn sValue     
EndProcedure

; ----- Testbereich -------

Procedure.i WebGadgetCB ( idGadget.i , sURL.s )
     
   ; The Input-Feld of the main searchform has the name "search_keywords".
   Debug GetElementText ( idGadget , "search_keywords" )
 
   ProcedureReturn #True
EndProcedure

Define.i idWindow
Define.i idWebGadget

idWindow    = OpenWindow ( #PB_Any , #PB_Ignore , #PB_Ignore , 800 , 600 , "test" , #PB_Window_ScreenCentered | #PB_Window_SystemMenu )
idWebGadget = WebGadget ( #PB_Any , 0 , 0 , 800 , 600 , "http://purebasic-lounge.com/search.php" )

SetGadgetAttribute ( idWebGadget , #PB_Web_NavigationCallback , @ WebGadgetCB () )

Repeat
   Select WaitWindowEvent ()
      Case #PB_Event_CloseWindow
      End
     
   EndSelect
ForEver

DataSection
  IID_IHTMLDocument3:      ; { 3050F485-98B5-11CF-BB82-00AA00BDCE0B }
  Data.l $3050F485
  Data.w $98B5 , $11CF
  Data.b $BB , $82 , $00 , $AA , $00 , $BD , $CE , $0B
  IID_IHTMLElement2:       ; { 3050f434-98b5-11cf-bb82-00aa00bdce0b }
  Data.l $3050F434
  Data.w $98B5 , $11CF
  Data.b $BB , $82 , $00 , $AA , $00 , $BD , $CE , $0B
  IID_IHTMLInputElement:   ; { 3050f5d2-98b5-11cf-bb82-00aa00bdce0b }
  Data.l $3050F5D2
  Data.w $98B5 , $11CF
  Data.b $BB , $82 , $00 , $AA , $00 , $BD , $CE , $0B
EndDataSection

Posted: Thu May 14, 2009 10:26 am
by idle
great needed that!

Re: Text of INPUT elements in webgadget

Posted: Wed Mar 29, 2017 5:57 pm
by incaroad
Hi Hroudtwolf!

How to do it on this website: http://www.tippmix.hu/sportfogadas

Thank you for your reply!

Re: Text of INPUT elements in webgadget

Posted: Wed Mar 29, 2017 10:04 pm
by walbus
Last visited: Dec 2013

His website is down, more i know not

Re: Text of INPUT elements in webgadget

Posted: Thu Mar 30, 2017 8:18 am
by incaroad
:(

Someone else could help me?
How might rewrite the program this home page: (http://www.tippmix.hu/sportfogadas)
Many thanks!