Seleccionar Categoria en pagina web

Pregunta Sin Miedo no te cortes cualquier cosa para empezar - Autoit se comienza facilmente.Para Ordenes o Comandos sueltos. Ver nota como preguntar.
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Hola buen dia, estuve buscando en el foro pero no encontre lo que necesito. Aqui va la consulta.
Arme un programa para subir wallpapers a mi web, ya funciona perfecto, ahora me gustaria agregarle un selector de categorias.

En mi web el cuadro de categorias es el siguiente:

Código: Seleccionar todo

<select class="agregar required" tabindex="5" size="9" style="width:300px;" name="cid">
<option value="" selected="selected" style="color: #000; font-weight: bold; padding: 3px; background:none;">Elegir una categoria</option>

<option value="1" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/flash.png)">Arquitectura</option>
<option value="2" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/report.png)">Animales</option>
<option value="34" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Blanco y Negro</option>
<option value="35" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Cartoons</option>
<option value="36" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Celebrities</option>
<option value="37" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">City</option>
<option value="38" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Computers</option>
<option value="39" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Cute</option>
<option value="40" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Elements</option>
<option value="41" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Food and Drink</option>
<option value="42" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Funny</option>
<option value="43" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Games</option>
<option value="44" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Girls</option>
<option value="45" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Holidays</option>
<option value="46" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Love</option>
<option value="47" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Motors</option>
<option value="48" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Movies</option>
<option value="49" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Music</option>
<option value="50" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Nature</option>
<option value="51" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Seasons</option>
<option value="52" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Space</option>
<option value="53" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Sports</option>
<option value="54" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Travel</option>
<option value="55" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Vintage</option>
<option value="56" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">3D</option>
<option value="57" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Anime</option>
<option value="58" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Fantasy</option>
<option value="59" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Motorcycle</option>
<option value="60" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Meme</option>
<option value="61" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Beach</option>
<option value="62" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Others</option>
<option value="63" style="background-image:url(http://tolchx.com/themes/AZ-Theme/images/icons/cat/car.png)">Flowers</option>
</select>

se me habia ocurrido algo asi:

Código: Seleccionar todo

$oSubmit = _IEGetObjByValue($oIE, "6")
_IEAction ($oSubmit, "click")
Pero me parece que _IEGetObjByValue no es valido.


Como podria adaptar mi programa para que si seleccionan la categoria: Movies (48)
Cuando llegue el proceso de subir el wallpapers a mi web seleccione dicha categoria.

Aca el script de mi programa:

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>

;===================================
;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", 433, 276, 193, 125)
$creador = GUICtrlCreateInput("Tu Nombre", 110, 24, 225, 21)
GUICtrlSetCursor(-1, 5)
$Nombre = GUICtrlCreateInput("Nombre de la imagen", 110, 56, 225, 21)
GUICtrlSetCursor(-1, 5)
$pagina = GUICtrlCreateInput("URL de la imagen", 50, 100, 355, 21)
GUICtrlSetCursor(-1, 5)
$Button1 = GUICtrlCreateButton("Aceptar", 140, 152, 153, 57, 0)
GUICtrlSetCursor(-1, 0)
$Pic1 = GUICtrlCreatePic(@TempDir & "\timage.jpg", -8, -16, 440, 303, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)

$Checkbox5 = GUICtrlCreateCheckbox("Derecha", 464, 200, 81, 17)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

;===================================
;Login
;===================================

While 1

   $msg = GUIGetMsg()
   Select
      Case $msg = $GUI_EVENT_CLOSE
         Exit
      Case $msg = $Button1
         _createtheme()


   EndSelect
WEnd

;===================================
;Cuadro Loading
;===================================

#Region ### START Koda GUI section ### Form=
$IeObj = _IECreateEmbedded ()
$Form2 = GUICreate("Subiendo Fondo", 225, 90, 300, 305)
GUISetBkColor(0xFFFFFF)
$Label2 = GUICtrlCreateLabel("        CARGANDO....", 56, 70, 274, 16)
GUICtrlSetFont(-1, 8, 400, 0, "WST_Swed")
GUICtrlSetColor(-1, 0x99B4D1)
$GUIActiveX = GUICtrlCreateObj($IeObj, -10, 10, 400, 50)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

_IENavigate ($IeObj, "http://www.tolchx.com/img/ajaxloader.gif")
Func _createtheme()
   $IeObj = _IECreate("http://userstyles.org/logout", 0, 0)

   _IENavigate($IeObj, "http://userstyles.org/login/?view=password", 0x1000)
   _IELoadWait($IeObj)
   $ieform = _IEFormGetCollection($IeObj, 1)

   $nombres = _IEGetObjById($IeObj, "login-existing")
   $nombres.value = "user"
   $apellidos = _IEGetObjById($IeObj, "password-existing")
   $apellidos.value = "pass"

   _IEFormSubmit($ieform)
   _IELoadWait($IeObj)

   _ReplaceStringInFile(@ScriptDir & "\Plantilla.txt", "imagen.jpg", GUICtrlRead($pagina))

   $file = FileRead(@ScriptDir & "/plantilla.txt")
   $final = _StringBetween($file, "<html>", "</html>")
   Sleep(2000)

;===================================
; Cambia a pagina de creacion
;===================================

   _IENavigate($IeObj, "http://userstyles.org/styles/new", 0x1000)
   _IELoadWait($IeObj)

   $Inpshort = _IEGetObjById($IeObj, "style_short_description")
   $Inplong = _IEGetObjById($IeObj, "style_long_description")
   $Inpcss = _IEGetObjById($IeObj, "css")
   $example=_IEGetObjByid($IeObj, "example-url")

;===================================
;Contador aleatorio
;===================================

   $LowerLimit = 1
   $UpperLimit = 99
   $RandomNumber = Random($LowerLimit, $UpperLimit, 1)

;===================================
;Completando Formulario
;===================================

   _IEFormElementSetValue($Inpshort, "Wallpapers para Facebook - " & GUICtrlRead($Nombre) & " - " & $RandomNumber)
   _IEFormElementSetValue($Inplong, "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>")
   _IEFormElementSetValue($Inpcss, $final[0])
   _IeFormElementSetValue($example, "http://www.facebook.com/")

;===================================
;Selecciono Checkbox
;===================================

   $oShowAllBuildings = _IEGetObjById($IeObj, "license-ccbyncsa")
   _IEAction($oShowAllBuildings, "click")

   Sleep(500)

   $button = _IEGetObjByName($IeObj, "commit")
   _IEAction($button, "click")
   _IELoadWait($IeObj)


   Opt("WinTitleMatchMode", 2)
   $IeObj = _IEAttach("userstyles", "WindowTitle") ;miro las ventanas de IE por el título de ventana
   $direccion = _IEPropertyGet($IeObj, "locationurl") ;almaceno en la variable la dirección url.
   Sleep(2000)

;===================================
;Subiendo Script a Tolch
;===================================

   _IENavigate($IeObj, "http://tolchx.com/fotos/agregar.php", 0x1000)
   _IELoadWait($IeObj)

   $ftitle = _IEGetObjById($IeObj, "ftitle")
   $fdesc = _IEGetObjById($IeObj, "fdesc")
   $furl = _IEGetObjById($IeObj, "furl")

   _IEFormElementSetValue($ftitle, "Wallpapers para Facebook - " & GUICtrlRead($Nombre))
   _IEFormElementSetValue($fdesc, $direccion)
   _IEFormElementSetValue($furl, GUICtrlRead($pagina))

   $button = _IEGetObjByName($IeObj, "new")
   _IEAction($button, "click")

;===================================
;Deja plantilla.txt con la imagen.jpg
;===================================

   _ReplaceStringInFile(@ScriptDir & "\" & "Plantilla.txt", GUICtrlRead($pagina), "imagen.jpg")

   MsgBox(0, "Listo!", "Wallpaper creado con exito :D")

EndFunc   ;==>_createtheme

PD: la seccion donde sube el wallpapers a mi web es a partir de :

;===================================
;Subiendo Script a Tolch
;===================================
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Seleccionar Categoria en pagina web

Mensaje por Dany »

Pero para ello tu aplicación no requiere un combobox? así le das la opción de elegir. realmente no entiendo muy bien que quieres hacer.

Saludos :smt027
  • ............................................Imagen
    ......................................Imagen
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Sii lo que necesito es agregar este selector de categorias que señala la fecha:

Imagen

Pero no se como hacerlo.
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Si , es el combobox el que necesito, no sabia que tenia ese nombre.
Voy a probar meterlo en el programa, pero necesitare luego ayuda para que cuando seleccionen una categoria en mi programa, luego seleccione la misma en mi web.

Un problema menos, ya logre adaptar el combobox:

Imagen

me quedo asi la caja de mi programa:

Código: Seleccionar todo

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", 433, 276, 193, 125)
$creador = GUICtrlCreateInput("Tu Nombre", 110, 24, 225, 21)
GUICtrlSetCursor(-1, 5)
$Nombre = GUICtrlCreateInput("Nombre de la imagen", 110, 56, 225, 21)
GUICtrlSetCursor(-1, 5)
$pagina = GUICtrlCreateInput("URL de la imagen", 50, 100, 355, 21)
GUICtrlSetCursor(-1, 5)
$Button1 = GUICtrlCreateButton("Aceptar", 140, 182, 153, 57, 0)
GUICtrlSetCursor(-1, 0)
$Combo1 = GUICtrlCreateCombo("", 140, 132, 153, 57, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
GUICtrlSetData(-1, "Seleccionar Categoria|Arquitectura|Animales|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", "Seleccionar Categoria")
$Pic1 = GUICtrlCreatePic(@TempDir & "\timage.jpg", -8, -16, 440, 303, BitOR($SS_NOTIFY, $WS_GROUP, $WS_CLIPSIBLINGS))

GUISetState(@SW_SHOW)


#EndRegion ### END Koda GUI section ###
Solo me faltaria hacer que al seleccionar una categoria, la seleccione en mi web, mientras espero ayuda lo intentare hacer yo, gracias Dany!
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

encontre en otro foro de autoit algo: https://www.autoitscript.com/autoit3/do ... Select.htm


Por lo que entendi trate de armar algo pero no funciono:

Código: Seleccionar todo

   _IELoadWait($IeObj)
   $oForm = _IEFormGetObjByName($IeObj,"cid")
   $oSelect = _IEFormElementGetObjByName($oForm, "cid")
   _IEFormElementOptionSelect($oSelect, "3", 1, "byValue")

Bien voy avanzando, solucione la seleccion de categoria en mi web haciendo lo siguiente:

Código: Seleccionar todo

	   #include <IE.au3>

$oIE = _IECreate("http://tolchx.com/fotos/agregar.php")
$oForm = _IEFormGetObjByName($oIE, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Humor", 1, "byText")
Ahora tengo que pensar la forma de mandar la variable del combobox a esa parte del codigo para seleccionar la categoria elegida
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Seleccionar Categoria en pagina web

Mensaje por Dany »

Fuera mas facil crear un archivo php que acepte un metodo post. (no te ayudo mucho sobre IE porque no domino mucho)

saludos
  • ............................................Imagen
    ......................................Imagen
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Ya lo solucione de esta forma:


While 1
If GUICtrlRead($n1)="Arquitectura" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Arquitectura", 1, "byText")
EndIf

If GUICtrlRead($n1)="Animales" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Animales", 1, "byText")
EndIf

If GUICtrlRead($n1)="Blanco y Negro" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Blanco y Negro", 1, "byText")
EndIf
WEnd

Tengo que seguir agregandole categorias, ese es un ejemplo con 3
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Lo que si, tengo minimo problema, y es que no sale de While 1, selecciona la categoria pero no avanza al proximo paso , de que forma podria solucionarlo?

SOLUCIONADO: : elimine el While 1 que venia por defecto en el ejemplo que vi, y ahora funciona perfecto.


Ya esta el programa al 99% , solo me faltaria hacer que no sea necesario tener que usar un .txt para tomar el script que subo a mi web con mi programa.
Pero es un detalle minimo. :)


Gracias!
Avatar de Usuario
Chefito
Profesional del Autoit
Mensajes: 2035
Registrado: 21 Feb 2008, 18:42
Ubicación: Albacete/Cuenca (España)

Re: Seleccionar Categoria en pagina web

Mensaje por Chefito »

Compañero, cuelga el código que lleves hecho y te ayudaré a mejorarlo y a reducirlo. Se me ocurren varias cosas para hacer eso :smt003 :smt023 .
iamchavo escribió:solo me faltaria hacer que no sea necesario tener que usar un .txt para tomar el script que subo a mi web con mi programa.
Esta parte no acabo de comprenderla bien. Es que subes el script autoit al servidor y lo ejecutas allí? :smt017 . Explícate mejor.

Saludos.
Cita vista en algún lugar de la red: En este mundo hay 10 tipos de personas, los que saben binario y los que no ;).
Avatar de Usuario
Dany
Profesional del Autoit
Mensajes: 651
Registrado: 28 Mar 2012, 22:49

Re: Seleccionar Categoria en pagina web

Mensaje por Dany »

chefito si es el hombre de IE. :) (andas perdido)

chefito para no tener un txt con el programa. yo le dije que lo pasara a binario y lo tengo dentro del mismo exe. o tenerlo en el servidor y leerlo.

Saludos
  • ............................................Imagen
    ......................................Imagen
Avatar de Usuario
Chefito
Profesional del Autoit
Mensajes: 2035
Registrado: 21 Feb 2008, 18:42
Ubicación: Albacete/Cuenca (España)

Re: Seleccionar Categoria en pagina web

Mensaje por Chefito »

Sí, la verdad es que hace un montón que no me metía. Como vi un poco parado el foro, me despreocupe un poco :smt033 .
Pero sin problem, para eso hay gente que sabe como tú :smt002 .

Ya, acabo de leer lo del exe y el txt en el otro hilo. Es que no sabía por donde iban los tiros solo leyendo esto.
Pienso que lo que le preocupa es que la gente tenga que tener dos archivos distintos. Ya le he dicho que lo incluya con el fileinstall y punto. Es lo más fácil :smt002 .

Saludos.
Cita vista en algún lugar de la red: En este mundo hay 10 tipos de personas, los que saben binario y los que no ;).
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Buenas tardes Chefito, me alegra saber de usted jaja, empeze en autoit por 2009, y gracias a tu ayuda y la de otros aprendi a entender un poco mejor el mundo de la programacion,, hoy en dia mi proyecto actual es el siguiente www.tolchx.com.
Tiene dos secciones una para subir POST y otra para installar wallpapers en Facebook , como era todo muy repetitivo, me acorde del magico Autoit! , y aqui me tienes, despues de 6 años retomando , ya que en esa epoca habia echo un programa parecido, me puse a leer todo lo que habia preguntado y armado en esa epoca y me volvio el conocimiento a la mente jaja.

Ya esta listo el script del programa, lo que pude hacer por ahora es lo siguiente, seguro se puede resumir:

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>
;===================================
;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", 433, 276, 193, 125)
$creador = GUICtrlCreateInput("Tu Nombre", 110, 24, 225, 21)
GUICtrlSetCursor(-1, 5)
$Nombre = GUICtrlCreateInput("Nombre de la imagen", 110, 56, 225, 21)
GUICtrlSetCursor(-1, 5)
$pagina = GUICtrlCreateInput("URL de la imagen", 50, 100, 355, 21)
GUICtrlSetCursor(-1, 5)
$Button1 = GUICtrlCreateButton("Aceptar", 140, 182, 153, 57, 0)
GUICtrlSetCursor(-1, 0)
$n1 = GUICtrlCreateCombo("", 140, 132, 153, 57, BitOR($CBS_DROPDOWN, $CBS_AUTOHSCROLL))
$Cat = GUICtrlSetData(-1, "Seleccionar Categoria|Arquitectura|Animales|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", "Seleccionar Categoria")
$Pic1 = GUICtrlCreatePic(@TempDir & "\timage.jpg", -8, -16, 440, 303, 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
         _createtheme()


   EndSelect
WEnd

Func _createtheme()
   $IeObj = _IECreate("http://userstyles.org/logout", 0,0)

   _IENavigate($IeObj, "http://userstyles.org/login/?view=password", 0x1000)
   _IELoadWait($IeObj)
   $ieform = _IEFormGetCollection($IeObj, 1)

   $nombres = _IEGetObjById($IeObj, "login-existing")
   $nombres.value = "user"
   $apellidos = _IEGetObjById($IeObj, "password-existing")
   $apellidos.value = "pass"

   _IEFormSubmit($ieform)
   _IELoadWait($IeObj)

   _ReplaceStringInFile(@ScriptDir & "\Plantilla.txt", "imagen.jpg", GUICtrlRead($pagina))

   $file = FileRead(@ScriptDir & "/plantilla.txt")
   $final = _StringBetween($file, "<html>", "</html>")
   Sleep(2000)

;===================================
; Cambia a pagina de creacion
;===================================

   _IENavigate($IeObj, "http://userstyles.org/styles/new", 0x1000)
   _IELoadWait($IeObj)

   $Inpshort = _IEGetObjById($IeObj, "style_short_description")
   $Inplong = _IEGetObjById($IeObj, "style_long_description")
   $Inpcss = _IEGetObjById($IeObj, "css")
   $example=_IEGetObjByid($IeObj, "example-url")

;===================================
;Contador aleatorio
;===================================

   $LowerLimit = 1
   $UpperLimit = 99
   $RandomNumber = Random($LowerLimit, $UpperLimit, 1)

;===================================
;Completando Formulario
;===================================

   _IEFormElementSetValue($Inpshort, "Wallpapers para Facebook - " & GUICtrlRead($Nombre) & " - " & $RandomNumber)
   _IEFormElementSetValue($Inplong, "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>")
   _IEFormElementSetValue($Inpcss, $final[0])
   _IeFormElementSetValue($example, "http://www.facebook.com/")

;===================================
;Selecciono Checkbox
;===================================

   $oShowAllBuildings = _IEGetObjById($IeObj, "license-ccbyncsa")
   _IEAction($oShowAllBuildings, "click")

   Sleep(500)

   $button = _IEGetObjByName($IeObj, "commit")
   _IEAction($button, "click")
   _IELoadWait($IeObj)


   Opt("WinTitleMatchMode", 2)
   $IeObj = _IEAttach("userstyles", "WindowTitle") ;miro las ventanas de IE por el título de ventana
   $direccion = _IEPropertyGet($IeObj, "locationurl") ;almaceno en la variable la dirección url.
   Sleep(2000)

;===================================
;Subiendo Script a Tolch
;===================================

   _IENavigate($IeObj, "http://tolchx.com/fotos/agregar.php", 0x1000)
   _IELoadWait($IeObj)

   $ftitle = _IEGetObjById($IeObj, "ftitle")
   $fdesc = _IEGetObjById($IeObj, "fdesc")
   $furl = _IEGetObjById($IeObj, "furl")

   _IEFormElementSetValue($ftitle, "Wallpapers para Facebook - " & GUICtrlRead($Nombre))
   _IEFormElementSetValue($fdesc, $direccion)
   _IEFormElementSetValue($furl, GUICtrlRead($pagina))

Sleep(1000)

If GUICtrlRead($n1)="Arquitectura" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Arquitectura", 1, "byText")
EndIf

If GUICtrlRead($n1)="Animales" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Animales", 1, "byText")
EndIf

If GUICtrlRead($n1)="Blanco y Negro" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Blanco y Negro", 1, "byText")
EndIf

If GUICtrlRead($n1)="Cartoons" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Cartoons", 1, "byText")
EndIf

If GUICtrlRead($n1)="Celebrities" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Celebrities", 1, "byText")
EndIf

If GUICtrlRead($n1)="City" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "City", 1, "byText")
EndIf

If GUICtrlRead($n1)="Computers" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Computers", 1, "byText")
EndIf

If GUICtrlRead($n1)="Cute" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Cute", 1, "byText")
EndIf

If GUICtrlRead($n1)="Elements" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Elements", 1, "byText")
EndIf

If GUICtrlRead($n1)="Food and Drink" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Food and Drink", 1, "byText")
EndIf

If GUICtrlRead($n1)="Funny" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Funny", 1, "byText")
EndIf

If GUICtrlRead($n1)="Games" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Games", 1, "byText")
EndIf

If GUICtrlRead($n1)="Girls" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Girls", 1, "byText")
EndIf

If GUICtrlRead($n1)="Holidays" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Holidays", 1, "byText")
EndIf

If GUICtrlRead($n1)="Love" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Love", 1, "byText")
EndIf

If GUICtrlRead($n1)="Motors" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Motors", 1, "byText")
EndIf

If GUICtrlRead($n1)="Movies" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Movies", 1, "byText")
EndIf

If GUICtrlRead($n1)="Music" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Music", 1, "byText")
EndIf

If GUICtrlRead($n1)="Nature" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Nature", 1, "byText")
EndIf

If GUICtrlRead($n1)="Seasons" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Seasons", 1, "byText")
EndIf

If GUICtrlRead($n1)="Space" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Space", 1, "byText")
EndIf

If GUICtrlRead($n1)="Sports" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Sports", 1, "byText")
EndIf

If GUICtrlRead($n1)="Travel" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Travel", 1, "byText")
EndIf

If GUICtrlRead($n1)="Vintage" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Vintage", 1, "byText")
EndIf

If GUICtrlRead($n1)="3D" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "3D", 1, "byText")
EndIf

If GUICtrlRead($n1)="Anime" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Anime", 1, "byText")
EndIf

If GUICtrlRead($n1)="Fantasy" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Fantasy", 1, "byText")
EndIf

If GUICtrlRead($n1)="Motorcycle" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Motorcycle", 1, "byText")
EndIf

If GUICtrlRead($n1)="Meme" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Meme", 1, "byText")
EndIf

If GUICtrlRead($n1)="Beach" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Beach", 1, "byText")
EndIf

If GUICtrlRead($n1)="Others" Then
$oForm = _IEFormGetObjByName($IeObj, "add_foto")
$oSelect = _IEFormElementGetObjByName($oForm, "cid")
_IEAction($oSelect, "focus")
_IEFormElementOptionSelect($oSelect, "Others", 1, "byText")
EndIf

Sleep(500)

   $button = _IEGetObjByName($IeObj, "new")
   _IEAction($button, "click")

;===================================
;Deja plantilla.txt con la imagen.jpg
;===================================

   _ReplaceStringInFile(@ScriptDir & "\" & "Plantilla.txt", GUICtrlRead($pagina), "imagen.jpg")

   MsgBox(0, "Listo!", "Wallpaper creado con exito :D")

EndFunc   ;==>_createtheme
Avatar de Usuario
Chefito
Profesional del Autoit
Mensajes: 2035
Registrado: 21 Feb 2008, 18:42
Ubicación: Albacete/Cuenca (España)

Re: Seleccionar Categoria en pagina web

Mensaje por Chefito »

Me he puesto a mirar tu código y me gustaría saber que hace exactamente este pedazo de código. No tengo claro que quieres hacer aquí.

Código: Seleccionar todo

   _ReplaceStringInFile(@ScriptDir & "\Plantilla.txt", "imagen.jpg", GUICtrlRead($pagina))

   $file = FileRead(@ScriptDir & "/plantilla.txt")
   $final = _StringBetween($file, "<html>", "</html>")
Saludos.
Cita vista en algún lugar de la red: En este mundo hay 10 tipos de personas, los que saben binario y los que no ;).
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Hola, esa parte del codigo lo que hace es lo siguiente:

el archivo Plantilla.txt contiene un script, el cual esta encerrado entre <html> </html>

Código: Seleccionar todo

<html>

....

body     {background-color: rgba(255,255,255,0.0) !important;}
html#facebook  {background: url("[b]imagen.jpg[/b]") fixed; background-size:100% auto;}

....

</html>
Entonces lo que hago es, remplazar imagen.jpg , por la url ingresada al principio cuando se abre el programa.
Luego selecciona todo el Script que se encuentra entre <html> y </html> ( Puse eso pero podria haber puesto <script> </script> o <inicio> </final> )

Al final cuando termina remplaza la url que se modifico en plantilla.txt y la cambia por imagen.jpg

Asi queda como antes y si quiero volver a subir un wallpaper puede volver a modifical esa parte del codigo
Avatar de Usuario
Chefito
Profesional del Autoit
Mensajes: 2035
Registrado: 21 Feb 2008, 18:42
Ubicación: Albacete/Cuenca (España)

Re: Seleccionar Categoria en pagina web

Mensaje por Chefito »

Claro, es que en el otro post donde ponías el código de plantilla.txt no estaba así esa parte y me estaba liando :smt003 .

Otra pregunta, el contenido del archivo plantilla.txt es siempre el mismo (exceptuando la sustitución que realizas de la imagen.jpg) o lo cambias en alguna ocasión? es que si es siempre el mismo, podrías meter el contenido en una variable y te ahorrarías el archivo externo.....además de incrementar mucho la velocidad.

De donde sale el archivo plantilla.txt? Es el contenido que tu recuperas de una web? No dejas nada claro como se procesa ese archivo plantilla.txt. Por lo menos en el código no sale.

Saludos.
Cita vista en algún lugar de la red: En este mundo hay 10 tipos de personas, los que saben binario y los que no ;).
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

El contenido de Plantilla.txt siempre es el mismo, salvo esa pequeña lonea "imagen.jpg" , que es la variable , se remplaza por la url de la imagen como mencione arriba.

plantilla.txt ya tiene un script dentro, ese codigo siempre esta ahi, no lo tomo de ninguna web. es un script que lo uso con la extencion stylish para chrome y firefox, el cual me permite cambiar el diseño de las paginas webs, en este caso Facebook.

De esa forma es que puedo poner wallpapers en facebook.

https://chrome.google.com/webstore/deta ... ?hl=es-419

Código: Seleccionar todo

Stylish es una extensión de Firefox/chrome que te permite cambiar el aspecto de tus páginas favoritas, modificando colores, posición y visibilidad de los elementos.

Desde su menú puedes buscar en la comunidad UserStyles un estilo asociado a la página que estás visitando e instalarlo con un clic. Stylish lo aplicará al instante.

Ya sea global o específico, cada aspecto puede superponerse o desactivarse con facilidad. Si quieres borrar o editar un estilo, Stylish cuenta con su propio Administrador de estilos.
No todos los estilos disponibles son igual de útiles, pero en algunos casos mejoran el aspecto o la usabilidad de los sitios más populares.
Avatar de Usuario
Chefito
Profesional del Autoit
Mensajes: 2035
Registrado: 21 Feb 2008, 18:42
Ubicación: Albacete/Cuenca (España)

Re: Seleccionar Categoria en pagina web

Mensaje por Chefito »

Ayer estuve probando rehaciendo tu código sin utilizar la udf ie, la cual tira del internet explorer. Lo tengo casi todo hecho. Estaba probando a ver si subía en tu web la imagen con todos los datos, y hoy me encuentro que me has bloqueado el usuario por repetir la subida de la misma imagen :smt005 . El usuario es autoit. Si me lo desbloqueas lo sigo intentando. Seguro que te resulta muy interesante el resultado :smt023 .

Saludos.
Cita vista en algún lugar de la red: En este mundo hay 10 tipos de personas, los que saben binario y los que no ;).
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Hola jajaja no te bloque el usuario, puse la subida de fotos solo para admins porque otros usuarios subian imagenes sin el link para instalar el script xD
ahora lo vuelvo a habilitar asi podes hacer las pruebas, ahora que estas probando el codigo se me ocurrio una idea:

Hacer que los usuarios de mi web si quieren crear su propio wallpaper, tengan que logearse desde el programa este que estamos creando :), asi evito poner mi usuario y contraseña personal dentro del codigo
iamchavo
Hacker del Foro
Mensajes: 134
Registrado: 26 Mar 2009, 22:46

Re: Seleccionar Categoria en pagina web

Mensaje por iamchavo »

Listo, te cambie el rango de usuario, asi los novatos no pueden subir imagenes, te puse como Great User , que si tienen habilitada la carga de imagenes, cualquier cosa avisame :)
Avatar de Usuario
Chefito
Profesional del Autoit
Mensajes: 2035
Registrado: 21 Feb 2008, 18:42
Ubicación: Albacete/Cuenca (España)

Re: Seleccionar Categoria en pagina web

Mensaje por Chefito »

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 :smt003 .

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 :smt003 . Como lo hacen muchos programas y muchas webs.

También puedes cuidar más la estética de la gui (ventana). Cosas así :smt023 .

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 :smt024 .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.
Adjuntos
archivosPrograma.zip
Archivo zip con el .au3, la udf winhttp entera, y la imagen de fondo redimensionada para que ocupe mucho menos.
(718.72 KiB) Descargado 189 veces
Cita vista en algún lugar de la red: En este mundo hay 10 tipos de personas, los que saben binario y los que no ;).
Responder