I have truble with auto submit and i dont know how i can put value in checkbox and radio box.
Problem:
1.Submit
When I Run program they never stop submition ,but i need only 1 submit.
2. Put value in checkbox and radio box.
How with this code?
And how get it all or 1 of list?
My test pageInterface IHTMLElementCollection_FIXED
QueryInterface(a, b)
AddRef()
Release()
GetTypeInfoCount(a)
GetTypeInfo(a, b, c)
GetIDsOfNames(a, b, c, d, e)
Invoke(a, b, c, d, e, f, g, h)
toString(a)
put_length(a)
get_length(a)
get__newEnum(a)
item(a1, a2, a3, a4, b1, b2, b3, b4, c)
tags(a, b)
EndInterface
Structure VARIANT_SPLIT
StructureUnion
Variant.VARIANT
Split.l[4]
EndStructureUnion
EndStructure
;Window
Enumeration
#Main
EndEnumeration
;Gadget
Enumeration
#Web
EndEnumeration
Global webBrowser.IWebBrowser2, Url.s, mail.s, Password.s, radio.s, checkbox.s
Url.s = "myweb.html"
mail.s = "test@gmail.com"
Password.s = "test"
radio.s = ""
checkbox.s = ""
Procedure Fill(*pElem.IHtmlElement)
Protected lFlags.l, *bstr.l, AttributeValue.VARIANT, Propriete.s
a = 0
If *pElem
lFlags.l = 1
If *pElem\getAttribute("type", lFlags, @AttributeValue) = #S_OK
If AttributeValue\vt = #VT_BSTR
If AttributeValue\bstrVal
Propriete = PeekS(AttributeValue\bstrVal, -1, #PB_Unicode)
SysFreeString_(@AttributeValue\bstrVal)
If Propriete = "text"
*bstr.l = SysAllocString_(Space((Len(mail)*2) + 2))
If *bstr
PokeS(*bstr, mail, -1, #PB_Unicode)
AttributeValue\bstrVal = *bstr
*pElem\SetAttribute("value", @AttributeValue, lFlags)
SysFreeString_(@*bstr)
EndIf
;Problem HERE
ElseIf Propriete = "checkbox"
*bstr.l = SysAllocString_(Space((Len(checkbox)*2) + 2))
If *bstr
PokeS(*bstr, checkbox, -1, #PB_Unicode)
AttributeValue\bstrVal = *bstr
*pElem\SetAttribute("value", @AttributeValue, lFlags)
SysFreeString_(@*bstr)
EndIf
ElseIf Propriete = "radio"
*bstr.l = SysAllocString_(Space((Len(radio)*2) + 2))
If *bstr
PokeS(*bstr, radio, -1, #PB_Unicode)
AttributeValue\bstrVal = *bstr
*pElem\SetAttribute("value", @AttributeValue, lFlags)
SysFreeString_(@*bstr)
EndIf
ElseIf Propriete = "submit"
*pElem\Click()
;AND HERE. Double submit and freez.
ElseIf Propriete = "image"
*pElem\Click()
Debug Propriete
ProcedureReturn 1
EndIf
EndIf
EndIf
EndIf
EndIf
ProcedureReturn 0
EndProcedure
Procedure ProcessElementCollection(*pElemColl.IHTMLElementCollection_FIXED)
Protected *pElemDisp.IDispatch = #Null
Protected *pElem.IHTMLElement = #Null
Protected a.l, long.l, *bstr.l
varIndex2.VARIANT_SPLIT\Variant\vt = #VT_I4
*pElemColl\get_length(@long.l)
For a = 0 To long-1
varIndex2.VARIANT_SPLIT\Variant\lval = a
If *pElemColl\item(varIndex2\split[0], varIndex2\split[1], varIndex2\split[2], varIndex2\split[3], varIndex2\split[0], varIndex2\split[1], varIndex2\split[2], varIndex2\split[3], @*pElemDisp.IDispatch) = #S_OK
If *pElemDisp
If *pElemDisp\QueryInterface(?IID_IHTMLElement, @*pElem.IHTMLElement) = #S_OK
If *pElem
*bstr.l = SysAllocString_(Space((10*2) + 2))
If *bstr
*pElem\Get_TagName(@*bstr)
If PeekS(*bstr, -1, #PB_Unicode) = "INPUT"
If Fill(*pElem.IHtmlElement)
a = long
EndIf
EndIf
SysFreeString_(@*bstr)
EndIf
*pElem\Release()
EndIf
EndIf
*pElemDisp\Release()
EndIf
EndIf
Next a
EndProcedure
Procedure ProcessDocument(*pDoc.IHTMLDocument2)
Protected *pElemColl.IHTMLElementCollection_FIXED = #Null
If *pDoc\get_all(@*pElemColl) = #S_OK
If *pElemColl
ProcessElementCollection(*pElemColl)
*pElemColl\Release()
EndIf
EndIf
EndProcedure
Procedure Auto_Login(Url.s)
Protected *pDispatch.IDispatch, *pDocument2.IHTMLDocument2
Protected hr.l
hr = WebBrowser\get_document(@*pDispatch)
If hr = 0 And *pDispatch>0
hr = *pDispatch\QueryInterface(?IID_IHTMLDocument2, @*pDocument2)
If hr = 0 And *pDocument2>0
ProcessDocument(*pDocument2)
*pDocument2\Release()
EndIf
*pDispatch\Release()
EndIf
EndProcedure
If OpenWindow(#Main, 0, 0, 800, 600, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(#Main))
WebGadget(#Web, 10, 10, 780, 580, URL.s)
webBrowser.IWebBrowser2 = GetWindowLong_(GadgetID(#Web), #GWL_USERDATA)
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_Gadget
Select EventGadget()
Case #Web
Select EventType()
Case #PB_EventType_DownloadEnd
Url.s = GetGadgetText(#Web)
Auto_Login(Url)
EndSelect
EndSelect
Case #WM_CLOSE
Quit = 1
EndSelect
Until Quit = 1
EndIf
End
DataSection
IID_IHTMLElement:
Data.l $3050F1FF
Data.w $98B5, $11CF
Data.b $BB, $82, $00, $AA, $00, $BD, $CE, $0B
IID_IHTMLDocument2:
Data.l $332C4425
Data.w $26CB, $11D0
Data.b $B4, $83, $00, $C0, $4F, $D9, $01, $19
EndDataSection
<html>
<body>
<form name="input" action="form_action.asp" method="get">
Male:
<input type="radio" name="Sex" value="Male" checked="checked" />
<br />
Female:
<input type="radio" name="Sex" value="Female" />
<br />
First name:
<input type="text" name="fname" value="Mickey" />
<br />
Last name:
<input type="text" name="lname" value="Mouse" />
<br />
I have a bike:
<input type="checkbox" name="vehicle" value="Bike" checked="checked" />
<br />
I have a car:
<input type="checkbox" name="vehicle" value="Car" />
<br />
I have an airplane:
<input type="checkbox" name="vehicle" value="Airplane" />
<br /><br />
<input name="submit" src="submit1.gif" alt="Submit Button" type="image">
</form>
<p>
</p>
</body>
</html>