Jump to content

Load Image from Webpage into Gui


Recommended Posts

I'm trying to automate account creation and need to load the security code so that its the only thing I have to enter is the security code. I dont know how to get it to load so I tried using _IEImgGetCollection to get the source for the file and InetGet to save the image, but it keeps saving as a blank file. I will post the code below any help is appreciated. THANK YOU!!!

This creates an empty file named vscode.gif in the script folder.

$oIE = _IECreate ("http://account.91.com/common/signup.aspx?url=http://co.91.com/&flag=co")

$oImg = _IEImgGetCollection ($oIE, 1)

$sInfo = $oImg.src

MsgBox(0, "2nd Image Info", $sInfo)

InetGet ($sInfo &".gif",@ScriptDir &"\vscode.gif",1)

#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

#Region ### START Koda GUI section ###
$CO2AC = GUICreate("CO2 Account Creator by B2DM", 448, 172, 191, 396)
$Account = GUICtrlCreateInput("Account", 22, 29, 121, 21)
$Password = GUICtrlCreateInput("Password", 25, 57, 121, 21)
$Email = GUICtrlCreateInput("Email", 26, 87, 121, 21)
$Name = GUICtrlCreateInput("Name", 154, 28, 121, 21)
$Ident = GUICtrlCreateInput("Ident", 154, 55, 121, 21)
$Question = GUICtrlCreateInput("Question", 154, 87, 121, 21)
$Answer = GUICtrlCreateInput("Answer", 290, 30, 121, 21)
$CheckCode = GUICtrlCreateInput("Code", 26, 118, 121, 21)
$OK = GUICtrlCreateButton("OK", 304, 104, 75, 25, 0)
$Check = GUICtrlCreateButton("Check", 304, 64, 75, 25, 0)
$Pic1 = GUICtrlCreatePic("", 184, 120, 69, 28, BitOR($SS_NOTIFY,$WS_GROUP,$WS_CLIPSIBLINGS))
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###

$oIE = _IECreate ("http://account.91.com/common/signup.aspx?url=http://co.91.com/&flag=co")
$oImg = _IEImgGetCollection ($oIE, 1)
$sInfo = $oImg.src
MsgBox(0, "2nd Image Info", $sInfo)
InetGet ($sInfo &".gif",@ScriptDir &"\vscode.gif",1)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $OK
            Create()
    EndSwitch
WEnd


Func Create()
$Account1 = GUICtrlRead($Account)
$Password1 = GUICtrlRead($Password)
$Name1 = GUICtrlRead($Name)
$Email1 = GUICtrlRead($Email)
$Ident1 = GUICtrlRead($Ident)
$Question1 = GUICtrlRead($Question)
$Answer1 = GUICtrlRead($Answer)
$CheckCode1 = GUICtrlRead($CheckCode)


$oForm = _IEFormGetObjByName ($oIE, "Form1")
$oText = _IEFormElementGetObjByName ($oForm, "txtAccount")
_IEFormElementSetValue ($oText, $Account1)
$oText1 = _IEFormElementGetObjByName ($oForm, "txtPassword")
_IEFormElementSetValue ($oText1, $Password1)
$oText2 = _IEFormElementGetObjByName ($oForm, "txtConfirmPassword")
_IEFormElementSetValue ($oText2, $Password1)
$oText3 = _IEFormElementGetObjByName ($oForm, "txtRealName")
_IEFormElementSetValue ($oText3, $Name1)
$oText4 = _IEFormElementGetObjByName ($oForm, "txtEmail")
_IEFormElementSetValue ($oText4, $Email1)
$oText5 = _IEFormElementGetObjByName ($oForm, "txtConfirmEmail")
_IEFormElementSetValue ($oText5, $Email1)
$oText6 = _IEFormElementGetObjByName ($oForm, "txtPaperCard")
_IEFormElementSetValue ($oText6, $Ident1)
$oText7 = _IEFormElementGetObjByName ($oForm, "txtConfirmPaperCard")
_IEFormElementSetValue ($oText7, $Ident1)
$oText8 = _IEFormElementGetObjByName ($oForm, "txtQuestion")
_IEFormElementSetValue ($oText8, $Question1)
$oText9 = _IEFormElementGetObjByName ($oForm, "txtAnswer")
_IEFormElementSetValue ($oText9, $Answer1)
$oText10 = _IEFormElementGetObjByName ($oForm, "txtConfirmAnswer")
_IEFormElementSetValue ($oText10, $Answer1)
$oText11 = _IEFormElementGetObjByName ($oForm, "txtCheckCode")
_IEFormElementSetValue ($oText11, $CheckCode1)
_IEFormElementCheckboxSelect ($oForm, "isAgreement", "", 1, "byIndex")
;_IEFormImageClick ($oForm, "imgbtn_reg", "name")
;_IEFormSubmit ($oForm)
;_IEQuit ($oIE)
;_IECreateEmbedded ("http://account.91.com/vscode.gif.aspx?pid=Validater1&s")
;http://account.91.com/vscode.gif.aspx?pid=Validater1&s
EndFunc
Edited by Learning
Link to comment
Share on other sites

I'm trying to automate account creation and need to load the security code so that its the only thing I have to enter is the security code. I dont know how to get it to load so I tried using _IEImgGetCollection to get the source for the file and InetGet to save the image, but it keeps saving as a blank file. I will post the code below any help is appreciated. THANK YOU!!!

This creates an empty file named vscode.gif in the script folder.

$oIE = _IECreate ("http://account.91.com/common/signup.aspx?url=http://co.91.com/&flag=co")

$oImg = _IEImgGetCollection ($oIE, 1)

$sInfo = $oImg.src

MsgBox(0, "2nd Image Info", $sInfo)

InetGet ($sInfo &".gif",@ScriptDir &"\vscode.gif",1)

Why are you adding ".gif" to the source in $sInfo? What does $sInfo look like when you see it in the MsgBox? Are you sure '$sInfo & ".gif"' is a valid path you are passing to InetGet?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Why are you adding ".gif" to the source in $sInfo? What does $sInfo look like when you see it in the MsgBox? Are you sure '$sInfo & ".gif"' is a valid path you are passing to InetGet?

:)

The messege box looks like this but the part after Validater1&s always changes. I also changed it so that the code looks like this since you pointed out an error on my part ,but still puts an empty file in the script directory.

$oIE = _IECreate ("http://account.91.com/common/signup.aspx?url=http://co.91.com/&flag=co")

$oImg = _IEImgGetCollection ($oIE, 1)

$sInfo = $oImg.src

MsgBox(0, "2nd Image Info", $sInfo)

InetGet ($sInfo,@ScriptDir & "\test",1)

http://account.91.com/vscode.gif.aspx?pid=...ba-b0befe0c5a0d

Link to comment
Share on other sites

The messege box looks like this...

account.91.com/vscode.gif.aspx?pid=Validater1&s=70b7b3c4-5baa-4c94-a0ba-b0befe0c5a0d

That's an aspx page, meaning there are ASP scripts assembling the page, and you probably can't just directly download an element from the page.

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

That's an aspx page, meaning there are ASP scripts assembling the page, and you probably can't just directly download an element from the page.

:)

Thanks for the info. I wonder if you can script right click and save as on that picture. I know I can do it manually so there has to be a way to save the picture. Again thanks for the help.

Link to comment
Share on other sites

Think I finished it Used a work around to get the captcha code to load but it finally works. Still a few bugs but it gets the job done. Here it is.

Clicking "Load" loads the captcha (so you can fill in the box)and "Write" writes the info and submits it to the page.

#include <IE.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>

$Acnt = IniRead(@ScriptDir & "\CO2AC.ini", "ACCTINFO", "Key1", "NotFound")
$Pass = IniRead(@ScriptDir & "\CO2AC.ini", "ACCTINFO", "Key2", "NotFound")
$Nam = IniRead(@ScriptDir & "\CO2AC.ini", "ACCTINFO", "Key3", "NotFound")
$Eml = IniRead(@ScriptDir & "\CO2AC.ini", "ACCTINFO", "Key4", "NotFound")
$Id = IniRead(@ScriptDir & "\CO2AC.ini", "ACCTINFO", "Key5", "NotFound")
$Quest = IniRead(@ScriptDir & "\CO2AC.ini", "ACCTINFO", "Key6", "NotFound")
$Answer1 = IniRead(@ScriptDir & "\CO2AC.ini", "ACCTINFO", "Key7", "NotFound")

_IEErrorHandlerRegister()
$oIE = _IECreateEmbedded()

#region ### START Koda GUI section ### Form=
GUICreate("CO2 Account Creator by B2DM", 400, 400, 600, 151)
;$CO2AC = GUICreate("CO2 Account Creator by B2DM", 388, 357, 600, 151)
$GUIActiveX = GUICtrlCreateObj($oIE, 100, 20, 150, 50)
$Account = GUICtrlCreateInput($Acnt, 56, 160, 121, 21)
$Password = GUICtrlCreateInput($Pass, 56, 200, 121, 21)
$Email = GUICtrlCreateInput($Eml, 56, 248, 121, 21)
$Name = GUICtrlCreateInput($Nam, 192, 160, 121, 21)
$Ident = GUICtrlCreateInput($Id, 192, 200, 121, 21)
$Question = GUICtrlCreateInput($Quest, 192, 248, 121, 21)
$Answer = GUICtrlCreateInput($Answer1, 192, 296, 121, 21)
$CheckCode = GUICtrlCreateInput("", 56, 296, 121, 21)
$OK = GUICtrlCreateButton("Write", 192, 328, 121, 21, 0)
$Check = GUICtrlCreateButton("Load", 56, 328, 121, 21, 0)
$Label1 = GUICtrlCreateLabel("Account", 88, 144, 65, 13)
$Label2 = GUICtrlCreateLabel("Password", 88, 184, 65, 13)
$Label3 = GUICtrlCreateLabel("Email", 96, 224, 65, 13)
$Label4 = GUICtrlCreateLabel("Name", 216, 144, 65, 13)
$Label7 = GUICtrlCreateLabel("Ident", 224, 184, 65, 13)
$Label6 = GUICtrlCreateLabel("Question", 216, 224, 65, 21)
$Label5 = GUICtrlCreateLabel("Answer", 224, 272, 41, 13)
$Label8 = GUICtrlCreateLabel("Check Code", 80, 272, 81, 13)
GUISetState(@SW_SHOW)
#endregion ### START Koda GUI section ### Form=

GUISetState();Show GUI

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Check
            _IENavigate($oIE, "http://account.91.com/common/signup.aspx?url=http://co.91.com/&flag=testtest", 1)
            $vCode = _IEGetObjById($oIE, "btn_check")
            _IEAction($vCode, "focus")
            $vCode = _IEGetObjById($oIE, "txtCheckCode")
            _IEAction($vCode, "focus")
        Case $OK
            $Account1 = GUICtrlRead($Account)
            $Password1 = GUICtrlRead($Password)
            $Name1 = GUICtrlRead($Name)
            $Email1 = GUICtrlRead($Email)
            $Ident1 = GUICtrlRead($Ident)
            $Question1 = GUICtrlRead($Question)
            $Answer1 = GUICtrlRead($Answer)
            $CheckCode1 = GUICtrlRead($CheckCode)
            $sIni = @DesktopDir & "\" & $Account1 & ".TXT"
            $sIni2 = @DesktopDir & "\CO2AC.ini"
            $sData = "NAME: " & $Account1 & @LF & "Password: " & $Password1 & @LF & "RealName: " & $Name1 & @LF & "Email: " & $Email1 & @LF & "IDENT: " & $Ident1 & @LF & "Question: " & $Question1 & @LF & "Answer: " & $Answer1
            $sData1 = "Key1=" & $Account1 & @LF & "Key2=" & $Password1 & @LF & "Key3=" & $Name1 & @LF & "Key4=" & $Email1 & @LF & "Key5=" & $Ident1 & @LF & "Key6=" & $Question1 & @LF & "Key7=" & $Answer1
            IniWriteSection($sIni, "ACCTINFO", $sData)
            IniWriteSection($sIni2, "ACCTINFO", $sData1)
            $oForm = _IEFormGetObjByName($oIE, "Form1")
            $oText = _IEFormElementGetObjByName($oForm, "txtAccount")
            _IEFormElementSetValue($oText, $Account1)
            $oText1 = _IEFormElementGetObjByName($oForm, "txtPassword")
            _IEFormElementSetValue($oText1, $Password1)
            $oText2 = _IEFormElementGetObjByName($oForm, "txtConfirmPassword")
            _IEFormElementSetValue($oText2, $Password1)
            $oText3 = _IEFormElementGetObjByName($oForm, "txtRealName")
            _IEFormElementSetValue($oText3, $Name1)
            $oText4 = _IEFormElementGetObjByName($oForm, "txtEmail")
            _IEFormElementSetValue($oText4, $Email1)
            $oText5 = _IEFormElementGetObjByName($oForm, "txtConfirmEmail")
            _IEFormElementSetValue($oText5, $Email1)
            $oText6 = _IEFormElementGetObjByName($oForm, "txtPaperCard")
            _IEFormElementSetValue($oText6, $Ident1)
            $oText7 = _IEFormElementGetObjByName($oForm, "txtConfirmPaperCard")
            _IEFormElementSetValue($oText7, $Ident1)
            $oText8 = _IEFormElementGetObjByName($oForm, "txtQuestion")
            _IEFormElementSetValue($oText8, $Question1)
            $oText9 = _IEFormElementGetObjByName($oForm, "txtAnswer")
            _IEFormElementSetValue($oText9, $Answer1)
            $oText10 = _IEFormElementGetObjByName($oForm, "txtConfirmAnswer")
            _IEFormElementSetValue($oText10, $Answer1)
            $oText11 = _IEFormElementGetObjByName($oForm, "txtCheckCode")
            _IEFormElementSetValue($oText11, $CheckCode1)
            _IEFormElementCheckBoxSelect($oForm, "isAgreement", "", 1, "byIndex")
            _IEFormImageClick($oForm, "imgbtn_reg", "name")
    ;_IEFormSubmit ($oForm)
    ;_IEQuit ($oIE)
    EndSwitch
WEnd

GUIDelete()

Exit
Edited by Learning
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...