Bueno, ya he hecho una alternativa a tu código. He utilizado la udf winhttp que utiliza el objeto winhttp. Para mí mucho mejor que la udf ie, ya que no utiliza el internet explorer...lo hace directamente todo a través de este objeto. Se consigue mucha más velocidad, y nunca te dará los problemas que te puede dar el internet explorer.
He utilizado dos funciones distintas con las que acceder a los formularios, para que veas como se puede hacer lo mismo de distinta forma.
También he cargado la imagen directamente en el compilado con la función fileinstall. He hecho algunas cosas más. He tratado mínimamente algunos posibles errores, aunque esto se podría hacer mucho mejor y con más situaciones no deseadas (ejemplo, con la función seterror). Ten en cuenta que pueden pasar muchas cosas, desde que no se carge las páginas por cualquier motivo, hasta que falle en algún punto por diversas causas. Esos errores tienes que intentar preeverlos y corregirlos lo mejor posible.
Por ejemplo, yo he hecho que el botón se deshabilite cuando se pulsa y mientras se está ejecutando la función, no sea que le de varias veces y por casualidad ocurra efectos no deseados.......aunque esto no tendría porque pasar, ya que mientras se está ejecutando el código de la función no debe detectar una nueva pulsación. Pero bueno, así también le indicas al usuario que lo está haciendo
.
Otra recomendación estética. Puedes hacer que salgan los textos explicativos en gris claro y hacer que cuando obtengan el foco estos inputs y el usuario empieze a escribir, se borre ese texto explicativo y solo se vea lo que está escribiendo el usuario en color negro. Y si el usuario borra todo y se queda en blanco de nuevo, que aparezca el texto explicativo de nuevo en gris
. Como lo hacen muchos programas y muchas webs.
También puedes cuidar más la estética de la gui (ventana). Cosas así
.
Yo simplemente he hecho un código rápido sin mucha floritura para que veas como se hace de esta forma y aprendas a hacerlo
.Mira el código, analízalo, mira en las ayudas, e intenta entenderlo. Si tienes alguna duda te la intentaré aclarar.
Dejo un archivo zip con el .au3, la udf winhttp entera, y la imagen de fondo redimensionada para que ocupe mucho menos.
Código: Seleccionar todo
;~ #include <File.au3>
;~ #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
;~ #include <WindowsConstants.au3>
;~ #include <String.au3>
;~ #include <IE.au3>
#include <StaticConstants.au3>
;~ #include <Misc.au3>
;~ #include <ButtonConstants.au3>
;~ #include <ComboConstants.au3>
;~ #include <GUIConstantsEx.au3>
;~ #include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <GuiComboBox.au3>
#include "WinHttp.au3"
#include <inet.au3>
FileInstall(".\mifondoTolchx.jpg",@TempDir & "\mifondoTolchx.jpg") ;al compilar el programa, cogerá la imagen llamada fondo.jpg que se debe poner en la ubicación del programa, y la copiará en los temporales de windows, para luego utilizarla como fondo de ventana.
;declaración de variables
Local $hOpen, $hConnect, $hRequest, $sRead
Local $css1='@-moz-document domain("facebook.com"){#contentCol,#headNavOut,#left_column,#navAccount,#navAccount ul,#right_column,.jewel,.jewelBox,.photo_container,.photo_table,.ufi_section{border:none!important}body{background-color:rgba(255,255,255,0)!important}html#facebook{background:url("'
Local $css2='")fixed;background-size:100% auto}body>#blueBar{background:0 0!important}.jewelBox{background-color:rgba(255,255,255,.9)!important}.fbTimelineCapsule,.timelineLayout #contentArea{background-color:rgba(255,255,255,.1)!important}#headNavOut{background:0 0!important}#pageNav a{color:#111!important}#pageNav a:hover{color:#333!important;background:0 0!important}#navAccount ul{background-color:rgba(255,255,255,.9)!important}#contentCol,#left_column,#right_column{background-color:rgba(255,255,255,.4)!important}#pagelet_main_column_personal,#timeline_tab_content{background-color:rgba(255,255,255,.1)!important;border:none!important}.add_comment_text,.box_header,.inputtext,.uiMorePager{background-color:rgba(255,255,255,.5)!important}.photo_container,.photo_table,.ufi_section{background:0 0!important}#ego,#pagelet_adbox,#sidebar_ads{display:none!important}#u_0_13,#u_0_1o,div#u_0_1n,u_0_2h{color:#00f;background:rgba(255,255,255,.5)}div#leftCol,div._5rzs{background:rgba(255,255,255,.4)}div#pagelet_canvas_nav_content,div._5qqe{background:#333;opacity:.1}div#u_0_0,div._4-u2.mbm._5v6e,div._5rzs{background:rgba(255,255,255,.3)}#blueBarHolder #blueBar,#blueBarNAXAnchor,div#blueBarNAXAnchor._4f7n._xxp.fixed_elem::after{background:#3a5795!important}.bubbles ._50kd ._kso,.bubbles div._kso{-webkit-border-radius:2px!important;background:0 0}.navLink{color:#fff!important}._rw{-webkit-filter:grayscale(20%);border-radius:5px!important}.bubbles div._kso{border:1px solid #B3D9FF}.fbNubFlyoutTitlebar{background:#3a5795!important;border:1px solid #3a5795!important;border-radius:1px!important}.uiSideNav .sideNavItem .hasCount:hover,.uiSideNav .sideNavItem .noCount:hover{text-shadow:2px 2px 2px rgba(57,255,20,.75)!important;color:#ff1414!important}.fbbody,.fbbody a{color:#00f}}@-moz-document url-prefix("https://www.facebook.com/pages"){div#rightCol{width:125px!important}div#u_0_0{width:980px!important}div#u_0_3h,div#u_0_3q{color:#00f;background:rgba(255,255,255,.5)}}@-moz-document domain("facebook.com"){.loggedout_menubar_container{background:0 0!important}.fbIndex #globalContainer #content,.fbIndex #globalContainer #dropmenu_container,.fbIndex #globalContainer #pageFooter{display:none!important}.login_form_label_field,.login_form_label_field a,label.uiInputLabelLabel{color:#666!important}.fbIndex .loggedout_menubar{width:auto!important}.fbIndex .loggedout_menubar_container{position:fixed!important;width:435px!important;height:82px!important;min-width:0!important;top:45%!important;left:5%!important}.loggedout_menubar{background:rgba(0,0,0,.6)!important;padding:0 10px 14px;-webkit-border-radius:6px;border-radius:6px;box-shadow:20px 20px 40px rgba(0,0,0,.5);border:1px solid #000}.fbFeedbackContent{background-color:rgba(255,255,255,.8)!important}._5vsj .UFIRow,._5vsj._5vsj._5vsj,UFIList,fbFeedTickerStory tickerStoryClickable,tickerActivityStories{background-color:rgba(255,255,255,0)!important}._1zw4,._4-u2,._4lh ._2-d1{background-color:rgba(255,255,255,.4)!important}._6m2{background-color:rgba(255,255,255,.5)!important}._4lh,.fbTimelineTimePeriod{background-color:rgba(255,255,255,0)!important}}'
Local $final
Local $RandomNumber
Local $htmlWebLogin, $token
Local $elemLista[]=["Seleccionar Categoria","Arquitectura","Animales","Arte","Autos y Motos","Celulares","Ciencia y Educación","Comics","Deporte","Downloads","E-books y Tutoriales","Ecología","Economía y Negocios","Femme","Hazlo tu mismo","Humor","Imágenes","Info","Juegos","Links","Linux","Mac","Manga y Anime","Mascotas","Música","Noticias","Off Topic","Recetas y Cocina","Salud y Bienestar","Solidaridad","Tolch","Turismo","TV, Peliculas y series","Videos On-line","Blanco y Negro","Cartoons","Celebrities","City","Computers","Cute","Elements","Food and Drink","Funny","Games","Girls","Holidays","Love","Motors","Movies","Music","Nature","Seasons","Space","Sports","Travel","Vintage","3D","Anime","Fantasy","Motorcycle","Meme","Beach","Others","Flowers"]
Local $cid, $direccion
;===================================
;Formulario
;===================================
;~ InetGet("http://www.criteriondg.info/wordpress/wp-content/themes/criterion/images/walls/33.jpg", @TempDir & "\timage.jpg")
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Tolchx.com por CHEFITO", 433, 380, 193, 125)
GUICtrlCreateLabel(" USERSTYLES.ORG", 10, 10, 110, 15)
GUICtrlSetBkColor(-1, 0xA9BCF5)
$userStyles = GUICtrlCreateInput("autoit", 10, 50, 150, 21)
$passStyles = GUICtrlCreateInput("autoit", 10, 80, 150, 21, $ES_PASSWORD)
GUICtrlCreateLabel(" TOLCHX.COM", 230, 10, 80, 15)
GUICtrlSetBkColor(-1, 0xA9BCF5)
$userTolchx = GUICtrlCreateInput("autoit2", 230, 50, 150, 21)
$passTolchx = GUICtrlCreateInput("autoit", 230, 80, 150, 21, $ES_PASSWORD)
$creador = GUICtrlCreateInput("Tu Nombre", 110, 170, 225, 21)
GUICtrlSetCursor(-1, 5)
$Nombre = GUICtrlCreateInput("Nombre de la imagen", 110, 200, 225, 21)
GUICtrlSetCursor(-1, 5)
$pagina = GUICtrlCreateInput("URL de la imagen", 50, 230, 355, 21)
GUICtrlSetCursor(-1, 5)
$Button1 = GUICtrlCreateButton("Aceptar", 280, 280, 100, 40)
GUICtrlSetCursor(-1, 0)
$list = GUICtrlCreateList("Arquitectura", 40, 270, 160, 90, $WS_BORDER + $WS_VSCROLL)
$Cat = GUICtrlSetData(-1, "Arquitectura|Animales|Arte|Autos y Motos|Celulares|Ciencia y Educación|Comics|Deporte|Downloads|E-books y Tutoriales|Ecología|Economía y Negocios|Femme|Hazlo tu mismo|Humor|Imágenes|Info|Juegos|Links|Linux|Mac|Manga y Anime|Mascotas|Música|Noticias|Off Topic|Recetas y Cocina|Salud y Bienestar|Solidaridad|Tolch|Turismo|TV, Peliculas y series|Videos On-line|Blanco y Negro|Cartoons|Celebrities|City|Computers|Cute|Elements|Food and Drink|Funny|Games|Girls|Holidays|Love|Motors|Movies|Music|Nature|Seasons|Space|Sports|Travel|Vintage|3D|Anime|Fantasy|Motorcycle|Meme|Beach|Others|Flowers", "Seleccionar Categoria")
$Pic1 = GUICtrlCreatePic(@ScriptDir & "\mifondoTolchx.jpg", 0, 0, 435, 380, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
;===================================
;Login
;===================================
While 1
$msg = GUIGetMsg()
Select
Case $msg = $GUI_EVENT_CLOSE
Exit
Case $msg = $Button1
GUICtrlSetState($button1,$GUI_DISABLE)
$resultado=_createtheme()
; Close connection handle
_WinHttpCloseHandle($hConnect)
; Close session handle
_WinHttpCloseHandle($hOpen)
If $resultado Then
MsgBox(64,"Hecho!!!","Se ha realizado todo bien ;)=")
EndIf
GUICtrlSetState($button1,$GUI_ENABLE)
EndSelect
WEnd
Func _createtheme()
$RandomNumber = Random(1, 99, 1)
$final=$css1 & GUICtrlRead($pagina) & $css2
; Initialize and get session handle
$hOpen = _WinHttpOpen()
; Get connection handle
$hConnect = _WinHttpConnect($hOpen, "userstyles.org")
; Make a request
$hRequest = _WinHttpSimpleSendRequest($hConnect, Default, "login/?view=password")
If $hRequest Then
; Simple-read...
$htmlWebLogin=_WinHttpSimpleReadData($hRequest)
;recupero el token de la página web
$token=StringRegExp($htmlWebLogin, '<input name="authenticity_token" type="hidden" value="(.*?)" />', 1)
Else
MsgBox(16, "Error", "Error ocurrido al intentar conectarte a la web userstyles.org." & @CRLF & "Error número: " & @error)
Return 0
EndIf
; Rellenar formulario para registrarte en la página web userstyle.org
$sRead = _WinHttpSimpleFormFillssl($hConnect, "login/?view=password", "index:1", "name:utf8", "✓", "name:authenticity_token", $token[0], "name:login", GUICtrlRead($userStyles), "name:password", GUICtrlRead($passStyles),"name:remember","true","name:view","password")
If @error Then
MsgBox(16, "Error", "Error ocurrido al intentar registrarte en la web userstyles.org." & @CRLF & "Error número: " & @error)
Return 0
EndIf
; Rellenar formulario para crear un nuevo estilo css en la página web userstyle.org
$sRead = _WinHttpSimpleFormFillSSL($hConnect, "styles/new", "index:0", "name:style[short_description]", "Wallpapers para Facebook - " & GUICtrlRead($Nombre) & " - " & $RandomNumber, "name:style[long_description]", "Imagen subida por: " & GUICtrlRead($creador) & "</br></br> Script Original: style 109959 creado por user 283811, Modificado por : Tolch </br></br></br></br><b>Mas Wallpapers para personalizar Facebook en http://www.Tolchx.com</b>","name:style[style_code_attributes][code]",$final,"name:style[screenshot_url_override]","http://www.facebook.com/","name:style[screenshot_type_preference]","auto","name:style[license]","ccbyncsa","name:style[id]","")
If @error Then
MsgBox(16, "Error", "Error ocurrido al intentar crear un nuevo estilo css en la web userstyles.org." & @CRLF & "Error número: " & @error)
Return 0
Else
$direccion=StringRegExp($sRead, '<link rel="canonical" href="(.*?)">', 1)
EndIf
;===================================
;Subiendo Script a Tolch
;===================================
; Get connection handle
$hConnect = _WinHttpConnect($hOpen, "tolchx.com")
;registro en tolchx.com
$sRead = _WinHttpSimpleSendRequest($hConnect, "post", "login-user.php",Default,"nick=" & _INetExplorerCapable(GUICtrlRead($userTolchx)) & "&pass=" & _INetExplorerCapable(GUICtrlRead($passTolchx)) & "&rem=true")
If @error Then
MsgBox(16, "Error", "Error ocurrido al intentar registrarse en la página web tolchx.com." & @CRLF & "Error número: " & @error)
Return 0
EndIf
;agregar foto en web tolchx.com
$sread=_WinHttpSimpleSendRequest($hConnect, "post", "fotos/agregar.php",Default,"titulo=Wallpapers para Facebook - " & _INetExplorerCapable(GUICtrlRead($Nombre)) & "&url=" & GUICtrlRead($pagina) & "&desc=" & $direccion[0])
If @error Then
MsgBox(16, "Error", "Error ocurrido al intentar agregar una foto en la página web tolchx.com." & @CRLF & "Error número: " & @error)
Return 0
EndIf
Return 1 ;devuelve 1 si todo se ha realizado bien....supuestamente :)
EndFunc ;==>_createtheme
; #FUNCTION# ;===============================================================================
; Name...........: _WinHttpSimpleFormFillSSL
; Description ...: Fills web form.
; Syntax.........: _WinHttpSimpleFormFillSSL(ByRef $hInternet [, $sActionPage = Default [, $sFormId = Default [, $sFieldId1 = Default [, $sData1 = Default [, (...)]]]]])
; Parameters ....: $hInternet - Handle returned by _WinHttpConnect() or string variable with form.
; $sActionPage - [optional] path to the page with form or session handle if $hInternet is string (default: "" - empty string; meaning 'default' page on the server in former).
; $sFormId - [optional] Id of the form. Can be name or zero-based index too (read Remarks section).
; $sFieldId1 - [optional] Id of the input.
; $sData1 - [optional] Data to set to coresponding field.
; (...) - [optional] Other pairs of Id/Data. Overall number of fields is 40.
; Return values .: Success - Returns HTML source of the page returned by the server on submitted form.
; Failure - Returns empty string and sets @error:
; |1 - No forms on the page
; |2 - Invalid form
; |3 - No forms with specified attributes on the page
; |4 - Connection problems
; |5 - form's "action" is invalid
; |6 - invalid session handle passed
; Author ........: trancexx, GMK
; Remarks .......: In case form requires redirection and [[$hInternet]] is internet handle, this handle will be closed and replaced with new and required one.
; +When [[$hInternet]] is form string, form's "action" must specify URL and [[$sActionPage]] parameter must be session handle. On succesful call this variable will be changed to connection handle of the internally made connection.
; Don't forget to close this handle after the function returns and when no longer needed.
; +[[$sFormId]] specifies Id of the form same as [[.getElementById(FormId)]]. Aditionally you can use [["index:FormIndex"]] to
; identify form by its zero-based index number (in case of e.g. three forms on some page first one will have index=0, second index=1, third index=2).
; Use [["name:FormName"]] to identify form by its name like with [[.getElementsByName(FormName)]]. FormName will be taken to be what's right of colon mark.
; In that case first form with that name is filled.
; +As for fields, If [["name:FieldName"]] option is used all the fields except last with that name are removed from the form. Last one is filled with specified $sData data.
; +This function can be used to fill forms with up to 40 fields at once.
; +"Submit" control you want to keep (click) set to True. If no such control is set then the first one found in the form is "clicked"
; and the other removed from the submitted form. "Checkbox" and "Button" input types are removed from the submitted form unless explicitly set. Same goes for "Radio" with exception that
; only one such control can be set, the rest are removed. These controls are set by their values. Wrong value makes them invalid and therefore not part of the submitted data.
; +All other non-set fields are left default.
; +Last (superfluous) argument will be treated as HTTP request header data to add.
; +
; +If this function is used to upload multiple files then there are two available ways. Default would be to submit the form following RFC2388 specification.
; In that case every file is represented as multipart/mixed part embedded within the multipart/form-data.
; +If you want to upload using alternative way (to avoid certain PHP bug that could exist on server side) then prefix the file string with [["PHP#50338:"]] string.
; +For example: [[..."name:files[]", "PHP#50338:" & $sFile1 & "|" & $sFile2 ...]]
; +Muliple files are always separated with vertical line ASCII character when filling the form.
; Related .......: _WinHttpConnect
;============================================================================================
Func _WinHttpSimpleFormFillSSL(ByRef $hInternet, $sActionPage = Default, $sFormId = Default, $sFieldId1 = Default, $sData1 = Default, $sFieldId2 = Default, $sData2 = Default, $sFieldId3 = Default, $sData3 = Default, $sFieldId4 = Default, $sData4 = Default, $sFieldId5 = Default, $sData5 = Default, $sFieldId6 = Default, $sData6 = Default, $sFieldId7 = Default, $sData7 = Default, $sFieldId8 = Default, $sData8 = Default, $sFieldId9 = Default, $sData9 = Default, $sFieldId10 = Default, $sData10 = Default, _
$sFieldId11 = Default, $sData11 = Default, $sFieldId12 = Default, $sData12 = Default, $sFieldId13 = Default, $sData13 = Default, $sFieldId14 = Default, $sData14 = Default, $sFieldId15 = Default, $sData15 = Default, $sFieldId16 = Default, $sData16 = Default, $sFieldId17 = Default, $sData17 = Default, $sFieldId18 = Default, $sData18 = Default, $sFieldId19 = Default, $sData19 = Default, $sFieldId20 = Default, $sData20 = Default, _
$sFieldId21 = Default, $sData21 = Default, $sFieldId22 = Default, $sData22 = Default, $sFieldId23 = Default, $sData23 = Default, $sFieldId24 = Default, $sData24 = Default, $sFieldId25 = Default, $sData25 = Default, $sFieldId26 = Default, $sData26 = Default, $sFieldId27 = Default, $sData27 = Default, $sFieldId28 = Default, $sData28 = Default, $sFieldId29 = Default, $sData29 = Default, $sFieldId30 = Default, $sData30 = Default, _
$sFieldId31 = Default, $sData31 = Default, $sFieldId32 = Default, $sData32 = Default, $sFieldId33 = Default, $sData33 = Default, $sFieldId34 = Default, $sData34 = Default, $sFieldId35 = Default, $sData35 = Default, $sFieldId36 = Default, $sData36 = Default, $sFieldId37 = Default, $sData37 = Default, $sFieldId38 = Default, $sData38 = Default, $sFieldId39 = Default, $sData39 = Default, $sFieldId40 = Default, $sData40 = Default)
#forceref $sFieldId1, $sData1, $sFieldId2, $sData2, $sFieldId3, $sData3, $sFieldId4, $sData4, $sFieldId5, $sData5, $sFieldId6, $sData6, $sFieldId7, $sData7, $sFieldId8, $sData8, $sFieldId9, $sData9, $sFieldId10, $sData10
#forceref $sFieldId11, $sData11, $sFieldId12, $sData12, $sFieldId13, $sData13, $sFieldId14, $sData14, $sFieldId15, $sData15, $sFieldId16, $sData16, $sFieldId17, $sData17, $sFieldId18, $sData18, $sFieldId19, $sData19, $sFieldId20, $sData20
#forceref $sFieldId21, $sData21, $sFieldId22, $sData22, $sFieldId23, $sData23, $sFieldId24, $sData24, $sFieldId25, $sData25, $sFieldId26, $sData26, $sFieldId27, $sData27, $sFieldId28, $sData28, $sFieldId29, $sData29, $sFieldId30, $sData30
#forceref $sFieldId31, $sData31, $sFieldId32, $sData32, $sFieldId33, $sData33, $sFieldId34, $sData34, $sFieldId35, $sData35, $sFieldId36, $sData36, $sFieldId37, $sData37, $sFieldId38, $sData38, $sFieldId39, $sData39, $sFieldId40, $sData40
__WinHttpDefault($sActionPage, "")
; Get page source
Local $hOpen, $sHTML, $fVarForm, $hRequest
If IsString($hInternet) Then ; $hInternet is page source
$sHTML = $hInternet
If _WinHttpQueryOption($sActionPage, $WINHTTP_OPTION_HANDLE_TYPE) <> $WINHTTP_HANDLE_TYPE_SESSION Then Return SetError(6, 0, "")
$hOpen = $sActionPage
$fVarForm = True
Else
$hRequest = _WinHttpOpenRequest($hInternet, Default, $sActionPage, Default, Default, Default, $WINHTTP_FLAG_SECURE)
_WinHttpAddRequestHeaders($hRequest, "Accept: text/html;q=0.9,text/plain;q=0.8,*/*;q=0.5")
_WinHttpSendRequest($hRequest)
_WinHttpReceiveResponse($hRequest)
If _WinHttpQueryDataAvailable($hRequest) Then
Do
$sHTML &= _WinHttpReadData($hRequest)
Until @error
EndIf
_WinHttpCloseHandle($hRequest)
EndIf
$sHTML = StringRegExpReplace($sHTML, "(?s)<!--.*?-->", "") ; removing comments
$sHTML = StringRegExpReplace($sHTML, "(?s)<!\[CDATA\[.*?\]\]>", "") ; removing CDATA
Local $fSend = False ; preset 'Sending flag'
; Find all forms on page
Local $aForm = StringRegExp($sHTML, "(?si)<\s*form\s*(.*?)<\s*/form\s*>", 3)
If @error Then Return SetError(1, 0, "") ; There are no forms available
; Process input
Local $fGetFormByName, $sFormName, $fGetFormByIndex, $fGetFormById, $iFormIndex
Local $aSplitForm = StringSplit($sFormId, ":", 2)
If @error Then ; like .getElementById(FormId)
$fGetFormById = True
Else
If $aSplitForm[0] = "name" Then ; like .getElementsByName(FormName)
$sFormName = $aSplitForm[1]
$fGetFormByName = True
ElseIf $aSplitForm[0] = "index" Then
$iFormIndex = Number($aSplitForm[1])
$fGetFormByIndex = True
Else ; like .getElementById(FormId)
$sFormId = $aSplitForm[0]
$fGetFormById = True
EndIf
EndIf
; Variables
Local $sForm, $sAttributes, $aAttributes, $aInput, $sAdditionalHeaders
Local $iNumArgs = @NumParams
If Not Mod($iNumArgs, 2) Then $sAdditionalHeaders = Eval("sFieldId" & $iNumArgs / 2 - 1)
Local $iNumParams = Ceiling(($iNumArgs - 2) / 2) - 1
Local $sAddData
Local $aCrackURL, $sNewURL, $iScheme = $INTERNET_SCHEME_HTTPS
; Loop thru all forms on the page and find one that was specified
For $iFormOrdinal = 0 To UBound($aForm) - 1
If $fGetFormByIndex And $iFormOrdinal <> $iFormIndex Then ContinueLoop
$sForm = $aForm[$iFormOrdinal]
; Extract form attributes
$sAttributes = StringRegExp($sForm, "(?s)(.*?)>", 3)
If Not @error Then $sAttributes = $sAttributes[0]
$aAttributes = StringRegExp($sAttributes, '\s*([^=]+)\h*=\h*(?:"|''|)(.*?)(?:"|''| |\Z)', 3) ; e.g. method="post" or method=post or method='post'
If @error Then Return SetError(2, 0, "") ; invalid form
If Mod(UBound($aAttributes), 2) Then ReDim $aAttributes[UBound($aAttributes) + 1]
Local $sAction = "", $sAccept = "", $sEnctype = "", $sMethod = "", $sName = "", $sId = ""
; Check set attributes
For $i = 0 To UBound($aAttributes) - 2 Step 2 ; array of form attributes
Switch $aAttributes[$i]
Case "action"
$sAction = StringReplace($aAttributes[$i + 1], "&", "&")
Case "accept"
$sAccept = $aAttributes[$i + 1]
Case "enctype"
$sEnctype = $aAttributes[$i + 1]
Case "id"
$sId = $aAttributes[$i + 1]
If $fGetFormById And $sFormId <> Default And $aAttributes[$i + 1] <> $sFormId Then ContinueLoop 2
Case "method"
$sMethod = $aAttributes[$i + 1]
Case "name"
$sName = $aAttributes[$i + 1]
If $fGetFormByName And $sFormName <> $sName Then ContinueLoop 2
EndSwitch
Next
If $sFormId <> Default And $fGetFormById And $sFormId <> $sId Then ContinueLoop
If $fGetFormByName And $sFormName <> $sName Then ContinueLoop
If Not $sMethod Then $sMethod = "GET"
If $sMethod = "GET" Then $sEnctype = ""
$aCrackURL = _WinHttpCrackUrl($sAction)
If @error Then
If $sAction Then
If StringLeft($sAction, 1) <> "/" Then
Local $sCurrent
Local $aURL = StringRegExp($sActionPage, '(.*)/', 3)
If Not @error Then $sCurrent = $aURL[0]
If $sCurrent Then $sAction = $sCurrent & "/" & $sAction
EndIf
If StringLeft($sAction, 1) = "?" Then $sAction = $sActionPage & $sAction
EndIf
If Not $sAction Then $sAction = $sActionPage
$sAction = StringRegExpReplace($sAction, "\A(/*\.\./)*", "") ; /../
Else
$iScheme = $aCrackURL[1]
$sNewURL = $aCrackURL[2]
$sAction = $aCrackURL[6] & $aCrackURL[7]
EndIf
If $fVarForm And Not $sNewURL Then Return SetError(5, 0, "") ; "action" must have URL specified
; Requested form is found. Set $fSend flag to true
$fSend = True
Local $aSplit, $sBoundary, $sPassedId, $sPassedData, $iNumRepl, $fMultiPart = False, $sSubmit, $sRadio, $sCheckBox, $sButton
Local $sGrSep = Chr(29)
$aInput = StringRegExp($sForm, "(?si)<\h*(?:input|textarea|label|fieldset|legend|select|optgroup|option|button)\h*(.*?)/*\h*>", 3)
If @error Then Return SetError(2, 0, "") ; invalid form
Local $aInputIds[4][UBound($aInput)]
Switch $sEnctype
Case "", "application/x-www-form-urlencoded"
For $i = 0 To UBound($aInput) - 1 ; for all input elements
__WinHttpFormAttrib($aInputIds, $i, $aInput[$i])
If $aInputIds[1][$i] Then ; if there is 'name' field then add it
$aInputIds[2][$i] = __WinHttpURLEncode($aInputIds[2][$i])
$sAddData &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & "&"
If $aInputIds[3][$i] = "submit" Then $sSubmit &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "submit" string
If $aInputIds[3][$i] = "radio" Then $sRadio &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "radio" string
If $aInputIds[3][$i] = "checkbox" Then $sCheckBox &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "checkbox" string
If $aInputIds[3][$i] = "button" Then $sButton &= $aInputIds[1][$i] & "=" & $aInputIds[2][$i] & $sGrSep ; add to overall "button" string
EndIf
Next
$sSubmit = StringTrimRight($sSubmit, 1)
$sRadio = StringTrimRight($sRadio, 1)
$sCheckBox = StringTrimRight($sCheckBox, 1)
$sButton = StringTrimRight($sButton, 1)
$sAddData = StringTrimRight($sAddData, 1)
For $k = 1 To $iNumParams
$sPassedData = __WinHttpURLEncode(Eval("sData" & $k))
$sPassedId = Eval("sFieldId" & $k)
$aSplit = StringSplit($sPassedId, ":", 2)
If @error Or $aSplit[0] <> "name" Then ; like .getElementById
For $j = 0 To UBound($aInputIds, 2) - 1
If $aInputIds[0][$j] = $sPassedId Then
If $aInputIds[3][$j] = "submit" Then
If $sPassedData = True Then ; if this "submit" is set to TRUE then
If $sSubmit Then ; If not already processed; only the first is valid
Local $fDelId = False
For $sChunkSub In StringSplit($sSubmit, $sGrSep, 3) ; go tru all "submit" controls
If $sChunkSub = $aInputIds[1][$j] & "=" & $aInputIds[2][$j] Then
If $fDelId Then $sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" & $sChunkSub & "\E(?:&|\Z)", "&", 1)
$fDelId = True
Else
$sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" & $sChunkSub & "\E(?:&|\Z)", "&") ; delete all but the TRUE one
EndIf
__WinHttpTrimBounds($sAddData, "&")
Next
$sSubmit = ""
EndIf
EndIf
ElseIf $aInputIds[3][$j] = "radio" Then
If $sPassedData = $aInputIds[2][$j] Then
For $sChunkSub In StringSplit($sRadio, $sGrSep, 3) ; go tru all "radio" controls
If $sChunkSub = $aInputIds[1][$j] & "=" & $sPassedData Then
$sAddData = StringRegExpReplace(StringReplace($sAddData, "&", "&&"), "(?i)(?:&|\A)\Q" & $aInputIds[1][$j] & "\E(.*?)(?:&|\Z)", "&")
$sAddData = StringReplace(StringReplace($sAddData, "&&", "&"), "&&", "&")
If StringLeft($sAddData, 1) = "&" Then $sAddData = StringTrimLeft($sAddData, 1)
$sAddData &= "&" & $sChunkSub
$sRadio = StringRegExpReplace(StringReplace($sRadio, $sGrSep, $sGrSep & $sGrSep), "(?i)(?:" & $sGrSep & "|\A)\Q" & $aInputIds[1][$j] & "\E(.*?)(?:" & $sGrSep & "|\Z)", $sGrSep)
$sRadio = StringReplace(StringReplace($sRadio, $sGrSep & $sGrSep, $sGrSep), $sGrSep & $sGrSep, $sGrSep)
EndIf
Next
EndIf
ElseIf $aInputIds[3][$j] = "checkbox" Then
$sCheckBox = StringRegExpReplace($sCheckBox, "(?i)\Q" & $aInputIds[1][$j] & "=" & $sPassedData & "\E" & $sGrSep & "*", "")
__WinHttpTrimBounds($sCheckBox, $sGrSep)
ElseIf $aInputIds[3][$j] = "button" Then
$sButton = StringRegExpReplace($sButton, "(?i)\Q" & $aInputIds[1][$j] & "=" & $sPassedData & "\E" & $sGrSep & "*", "")
__WinHttpTrimBounds($sButton, $sGrSep)
Else
$sAddData = StringRegExpReplace(StringReplace($sAddData, "&", "&&"), "(?i)(?:&|\A)\Q" & $aInputIds[1][$j] & "=" & $aInputIds[2][$j] & "\E(?:&|\Z)", "&" & $aInputIds[1][$j] & "=" & $sPassedData & "&")
$iNumRepl = @extended
$sAddData = StringReplace($sAddData, "&&", "&")
If $iNumRepl > 1 Then ; equalize ; TODO: remove duplicates
$sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" & $aInputIds[1][$j] & "\E=.*?(?:&|\Z)", "&", $iNumRepl - 1)
EndIf
__WinHttpTrimBounds($sAddData, "&")
EndIf
EndIf
Next
Else ; like .getElementsByName
For $j = 0 To UBound($aInputIds, 2) - 1
If $aInputIds[3][$j] = "submit" Then
If $sPassedData = True Then ; if this "submit" is set to TRUE then
If $aInputIds[1][$j] = $aSplit[1] Then
If $sSubmit Then ; If not already processed; only the first is valid
Local $fDel = False
For $sChunkSub In StringSplit($sSubmit, $sGrSep, 3) ; go tru all "submit" controls
If $sChunkSub = $aInputIds[1][$j] & "=" & $aInputIds[2][$j] Then
If $fDel Then $sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" & $sChunkSub & "\E(?:&|\Z)", "&", 1)
$fDel = True
Else
$sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" & $sChunkSub & "\E(?:&|\Z)", "&") ; delete all but the TRUE one
EndIf
__WinHttpTrimBounds($sAddData, "&")
Next
$sSubmit = ""
EndIf
ContinueLoop 2 ; process next parameter
EndIf
Else ; False means do nothing
ContinueLoop 2 ; process next parameter
EndIf
ElseIf $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "radio" Then
For $sChunkSub In StringSplit($sRadio, $sGrSep, 3) ; go tru all "radio" controls
If $sChunkSub = $aInputIds[1][$j] & "=" & $sPassedData Then
$sAddData = StringReplace(StringReplace(StringRegExpReplace(StringReplace($sAddData, "&", "&&"), "(?i)(?:&|\A)\Q" & $aInputIds[1][$j] & "\E(.*?)(?:&|\Z)", "&"), "&&", "&"), "&&", "&")
If StringLeft($sAddData, 1) = "&" Then $sAddData = StringTrimLeft($sAddData, 1)
$sAddData &= "&" & $sChunkSub
$sRadio = StringRegExpReplace(StringReplace($sRadio, $sGrSep, $sGrSep & $sGrSep), "(?i)(?:" & $sGrSep & "|\A)\Q" & $aInputIds[1][$j] & "\E(.*?)(?:" & $sGrSep & "|\Z)", $sGrSep)
$sRadio = StringReplace(StringReplace($sRadio, $sGrSep & $sGrSep, $sGrSep), $sGrSep & $sGrSep, $sGrSep)
EndIf
Next
ContinueLoop 2 ; process next parameter
ElseIf $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "checkbox" Then
$sCheckBox = StringRegExpReplace($sCheckBox, "(?i)\Q" & $aInputIds[1][$j] & "=" & $sPassedData & "\E" & $sGrSep & "*", "")
__WinHttpTrimBounds($sCheckBox, $sGrSep)
ContinueLoop 2 ; process next parameter
ElseIf $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "button" Then
$sButton = StringRegExpReplace($sButton, "(?i)\Q" & $aInputIds[1][$j] & "=" & $sPassedData & "\E" & $sGrSep & "*", "")
__WinHttpTrimBounds($sButton, $sGrSep)
ContinueLoop 2 ; process next parameter
EndIf
Next
$sAddData = StringRegExpReplace(StringReplace($sAddData, "&", "&&"), "(?i)(?:&|\A)\Q" & $aSplit[1] & "\E=.*?(?:&|\Z)", "&" & $aSplit[1] & "=" & $sPassedData & "&")
$iNumRepl = @extended
$sAddData = StringReplace($sAddData, "&&", "&")
If $iNumRepl > 1 Then ; remove duplicates
$sAddData = StringRegExpReplace($sAddData, "(?i)(?:&|\A)\Q" & $aSplit[1] & "\E=.*?(?:&|\Z)", "&", $iNumRepl - 1)
EndIf
__WinHttpTrimBounds($sAddData, "&")
EndIf
Next
__WinHttpFinalizeCtrls($sSubmit, $sRadio, $sCheckBox, $sButton, $sAddData, $sGrSep, "&")
If $sMethod = "GET" Then
$sAction &= "?" & $sAddData
$sAddData = "" ; not to send as addition to the request (this is GET)
EndIf
Case "multipart/form-data"
If $sMethod = "POST" Then ; can't be GET
$fMultiPart = True
; Define boundary line
$sBoundary = StringFormat("%s%.5f", "----WinHttpBoundaryLine_", Random(10000, 99999))
Local $sCDisp = 'Content-Disposition: form-data; name="'
For $i = 0 To UBound($aInput) - 1 ; for all input elements
__WinHttpFormAttrib($aInputIds, $i, $aInput[$i])
If $aInputIds[1][$i] Then ; if there is 'name' field
If $aInputIds[3][$i] = "file" Then
$sAddData &= "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$i] & '"; filename=""' & @CRLF & @CRLF & _
$aInputIds[2][$i] & @CRLF
Else
$sAddData &= "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$i] & '"' & @CRLF & @CRLF & _
$aInputIds[2][$i] & @CRLF
EndIf
If $aInputIds[3][$i] = "submit" Then $sSubmit &= "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$i] & '"' & @CRLF & @CRLF & _
$aInputIds[2][$i] & @CRLF & $sGrSep
If $aInputIds[3][$i] = "radio" Then $sRadio &= "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$i] & '"' & @CRLF & @CRLF & _
$aInputIds[2][$i] & @CRLF & $sGrSep
If $aInputIds[3][$i] = "checkbox" Then $sCheckBox &= "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$i] & '"' & @CRLF & @CRLF & _
$aInputIds[2][$i] & @CRLF & $sGrSep
If $aInputIds[3][$i] = "button" Then $sButton &= "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$i] & '"' & @CRLF & @CRLF & _
$aInputIds[2][$i] & @CRLF & $sGrSep
EndIf
Next
$sSubmit = StringTrimRight($sSubmit, 1)
$sRadio = StringTrimRight($sRadio, 1)
$sCheckBox = StringTrimRight($sCheckBox, 1)
$sButton = StringTrimRight($sButton, 1)
$sAddData &= "--" & $sBoundary & "--" & @CRLF
For $k = 1 To $iNumParams
$sPassedData = Eval("sData" & $k)
$sPassedId = Eval("sFieldId" & $k)
$aSplit = StringSplit($sPassedId, ":", 2)
If @error Or $aSplit[0] <> "name" Then ; like getElementById
For $j = 0 To UBound($aInputIds, 2) - 1
If $aInputIds[0][$j] = $sPassedId Then
If $aInputIds[3][$j] = "file" Then
$sAddData = StringReplace($sAddData, _
$sCDisp & $aInputIds[1][$j] & '"; filename=""' & @CRLF & @CRLF & $aInputIds[2][$j] & @CRLF, _
__WinHttpFileContent($sAccept, $aInputIds[1][$j], $sPassedData, $sBoundary))
ElseIf $aInputIds[3][$j] = "submit" Then
If $sPassedData = True Then ; if this "submit" is set to TRUE then
If $sSubmit Then ; If not already processed; only the first is valid
Local $fMDelId = False
For $sChunkSub In StringSplit($sSubmit, $sGrSep, 3) ; go tru all "submit" controls
If $sChunkSub = "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & _
$aInputIds[2][$j] & @CRLF Then
If $fMDelId Then $sAddData = StringReplace($sAddData, $sChunkSub, "", 1) ; Removing duplicates
$fMDelId = True
Else
$sAddData = StringReplace($sAddData, $sChunkSub, "") ; delete all but the TRUE one
EndIf
Next
$sSubmit = ""
EndIf
EndIf
ElseIf $aInputIds[3][$j] = "radio" Then
If $sPassedData = $aInputIds[2][$j] Then
For $sChunkSub In StringSplit($sRadio, $sGrSep, 3) ; go tru all "radio" controls
If StringInStr($sChunkSub, "--" & $sBoundary & @CRLF & $sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & $sPassedData & @CRLF) Then
$sAddData = StringRegExpReplace($sAddData, "(?i)\Q--" & $sBoundary & @CRLF & $sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & "\E" & "(.*?)" & @CRLF, "")
$sAddData = StringReplace($sAddData, "--" & $sBoundary & "--" & @CRLF, "")
$sAddData &= $sChunkSub & "--" & $sBoundary & "--" & @CRLF
$sRadio = StringRegExpReplace($sRadio, "(?i)\Q--" & $sBoundary & @CRLF & $sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & "\E(.*?)" & @CRLF & $sGrSep & "?", "")
EndIf
Next
EndIf
ElseIf $aInputIds[3][$j] = "checkbox" Then
$sCheckBox = StringRegExpReplace($sCheckBox, "(?i)\Q--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & _
$sPassedData & @CRLF & "\E" & $sGrSep & "*", "")
If StringRight($sCheckBox, 1) = $sGrSep Then $sCheckBox = StringTrimRight($sCheckBox, 1)
ElseIf $aInputIds[3][$j] = "button" Then
$sButton = StringRegExpReplace($sButton, "(?i)\Q--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & _
$sPassedData & @CRLF & "\E" & $sGrSep & "*", "")
If StringRight($sButton, 1) = $sGrSep Then $sButton = StringTrimRight($sButton, 1)
Else
$sAddData = StringReplace($sAddData, _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & $aInputIds[2][$j] & @CRLF, _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & $sPassedData & @CRLF)
$iNumRepl = @extended
If $iNumRepl > 1 Then ; equalize ; TODO: remove duplicates
$sAddData = StringRegExpReplace($sAddData, '(?si)\Q--' & $sBoundary & @CRLF & $sCDisp & $aInputIds[1][$j] & '"' & '\E\r\n\r\n.*?\r\n', "", $iNumRepl - 1)
EndIf
EndIf
EndIf
Next
Else ; like getElementsByName
For $j = 0 To UBound($aInputIds, 2) - 1
If $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "file" Then
$sAddData = StringReplace($sAddData, _
$sCDisp & $aSplit[1] & '"; filename=""' & @CRLF & @CRLF & $aInputIds[2][$j] & @CRLF, _
__WinHttpFileContent($sAccept, $aInputIds[1][$j], $sPassedData, $sBoundary))
ElseIf $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "submit" Then
If $sPassedData = True Then ; if this "submit" is set to TRUE then
If $sSubmit Then ; If not already processed; only the first is valid
Local $fMDel = False
For $sChunkSub In StringSplit($sSubmit, $sGrSep, 3) ; go tru all "submit" controls
If $sChunkSub = "--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & _
$aInputIds[2][$j] & @CRLF Then
If $fMDel Then $sAddData = StringReplace($sAddData, $sChunkSub, "", 1) ; Removing duplicates
$fMDel = True
Else
$sAddData = StringReplace($sAddData, $sChunkSub, "") ; delete all but the TRUE one
EndIf
Next
$sSubmit = ""
EndIf
ContinueLoop 2 ; process next parameter
Else ; False means do nothing
ContinueLoop 2 ; process next parameter
EndIf
ElseIf $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "radio" Then
For $sChunkSub In StringSplit($sRadio, $sGrSep, 3) ; go tru all "radio" controls
If StringInStr($sChunkSub, "--" & $sBoundary & @CRLF & $sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & $sPassedData & @CRLF) Then
$sAddData = StringRegExpReplace($sAddData, "(?i)\Q--" & $sBoundary & @CRLF & $sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & "\E" & "(.*?)" & @CRLF, "")
$sAddData = StringReplace($sAddData, "--" & $sBoundary & "--" & @CRLF, "")
$sAddData &= $sChunkSub & "--" & $sBoundary & "--" & @CRLF
$sRadio = StringRegExpReplace($sRadio, "(?i)\Q--" & $sBoundary & @CRLF & $sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & "\E(.*?)" & @CRLF & $sGrSep & "?", "")
EndIf
Next
ContinueLoop 2 ; process next parameter
ElseIf $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "checkbox" Then
$sCheckBox = StringRegExpReplace($sCheckBox, "(?i)\Q--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & _
$sPassedData & @CRLF & "\E" & $sGrSep & "*", "")
If StringRight($sCheckBox, 1) = $sGrSep Then $sCheckBox = StringTrimRight($sCheckBox, 1)
ContinueLoop 2 ; process next parameter
ElseIf $aInputIds[1][$j] = $aSplit[1] And $aInputIds[3][$j] = "button" Then
$sButton = StringRegExpReplace($sButton, "(?i)\Q--" & $sBoundary & @CRLF & _
$sCDisp & $aInputIds[1][$j] & '"' & @CRLF & @CRLF & _
$sPassedData & @CRLF & "\E" & $sGrSep & "*", "")
If StringRight($sButton, 1) = $sGrSep Then $sButton = StringTrimRight($sButton, 1)
ContinueLoop 2 ; process next parameter
EndIf
Next
$sAddData = StringRegExpReplace($sAddData, '(?si)\Q' & $sCDisp & $aSplit[1] & '"' & '\E\r\n\r\n.*?\r\n', _
$sCDisp & $aSplit[1] & '"' & @CRLF & @CRLF & StringReplace($sPassedData, "\", "\\") & @CRLF)
$iNumRepl = @extended
If $iNumRepl > 1 Then ; remove duplicates
$sAddData = StringRegExpReplace($sAddData, '(?si)\Q--' & $sBoundary & @CRLF & $sCDisp & $aSplit[1] & '"' & '\E\r\n\r\n.*?\r\n', "", $iNumRepl - 1)
EndIf
EndIf
Next
EndIf
__WinHttpFinalizeCtrls($sSubmit, $sRadio, $sCheckBox, $sButton, $sAddData, $sGrSep)
EndSwitch
ExitLoop
Next
; Send
If $fSend Then
If $fVarForm Then
$hInternet = _WinHttpConnect($hOpen, $sNewURL)
Else
If $sNewURL Then
$hOpen = _WinHttpQueryOption($hInternet, $WINHTTP_OPTION_PARENT_HANDLE)
_WinHttpCloseHandle($hInternet)
$hInternet = _WinHttpConnect($hOpen, $sNewURL)
EndIf
EndIf
If $iScheme = $INTERNET_SCHEME_HTTPS Then
$hRequest = __WinHttpFormSend($hInternet, $sMethod, $sAction, $fMultiPart, $sBoundary, $sAddData, True, $sAdditionalHeaders)
Else
$hRequest = __WinHttpFormSend($hInternet, $sMethod, $sAction, $fMultiPart, $sBoundary, $sAddData, False, $sAdditionalHeaders)
If _WinHttpQueryHeaders($hRequest, $WINHTTP_QUERY_STATUS_CODE) > $HTTP_STATUS_BAD_REQUEST Then
_WinHttpCloseHandle($hRequest)
$hRequest = __WinHttpFormSend($hInternet, $sMethod, $sAction, $fMultiPart, $sBoundary, $sAddData, True, $sAdditionalHeaders) ; try adding $WINHTTP_FLAG_SECURE
EndIf
EndIf
Local $sReturned = _WinHttpSimpleReadData($hRequest)
If @error Then
_WinHttpCloseHandle($hRequest)
Return SetError(4, 0, "") ; either site is expiriencing problems or your connection
EndIf
_WinHttpCloseHandle($hRequest)
Return $sReturned
EndIf
; If here then there is no form on the page with specified attributes (name, id or index)
Return SetError(3, 0, "")
EndFunc ;==>_WinHttpSimpleFormFillSSL
Saludos.