Jump to content
faustf

macro problem _IEBodyReadText

Recommended Posts

faustf

hi guy i  have created a macro for a webpag

e , the macro  login and press button , after i want  wait  as long as  not appear in html page a word  Benvenuto  , the  strange thigs  is:  i use Local $sHTML = _IEBodyReadText ($oIE)  for read  but inside of $sHTML is  empty  if i use consolewrite , but if i use msgbox  i show a part of html

 

#include <MsgBoxConstants.au3>
#include <WinAPIFiles.au3>
#include <File.au3>
#include <IE.au3>
#include <Array.au3>

Global $iCont_truck = 0
_Truckpooling_it_WEB()

Func _Truckpooling_it_WEB()

    If $CmdLine[0] = "" Or $CmdLine[0] = "?" Then
        _Help_truck()
    Else

        Local $sleepButt = 5000
        Local $sleepPass = 100
        If ProcessExists("iexplore.exe") Then ; Check if the internet esplorer process is running.
            ProcessClose("iexplore.exe")
        EndIf

        Global $oIE = _IECreate("http://www.truckpooling.it/", 0, 1, 1, 1) ; <--- 0011 invisible explorer  <--- 0111 visible explorer
        _IELoadWait($oIE)

        Local $oDiv = _IEGetObjById($oIE, "div_login-toggle")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oDiv)
        _IEAction($oDiv, "focus")
        _IEAction($oDiv, "Click")
        _IELoadWait($oIE)

        Local $oLogin = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtEmail")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oLogin)
        _IEAction($oLogin, "focus")
        _IEAction($oLogin, "Click")
        _IEFormElementSetValue($oLogin, $CmdLine[1]) ; user

        Local $oPassword = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtPassword")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oPassword)
        _IEAction($oPassword, "focus")
        _IEAction($oPassword, "Click")
        _IEFormElementSetValue($oPassword, $CmdLine[2]) ; password

        Local $oBottonLogin = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$btnLogin")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oBottonLogin)
        _IEAction($oBottonLogin, "focus")
        _IEAction($oBottonLogin, "Click")
        _IELoadWait($oIE)

        ;----  INSERISCI  SPEDIZIONI ---------------------------------------------------------------------


        Select
            Case $CmdLine[3] = "Buste"
                Local $oBuste = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$btnBusta")
                Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
                    Sleep(10)
                Until IsObj($oBuste)
                _IEAction($oBuste, "focus")
                _IEAction($oBuste, "Click")
                _IELoadWait($oIE)
            Case $CmdLine[3] = "Pacchi"
                ;   Local $oPacchi = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$btnCollo")
                ;   _IEAction($oPacchi, "focus")
                ;   _IEAction($oPacchi, "Click")

            Case $CmdLine[3] = "Pellets"
                Local $oPallet = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$btnPallet")
                Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
                    Sleep(10)
                Until IsObj($oPallet)
                _IEAction($oPallet, "focus")
                _IEAction($oPallet, "Click")
                _IELoadWait($oIE)
        EndSelect
        ; questo blocco va  abilitato per scegliere trasporot internazionale o meno
        
        MsgBox(0,'','sono qui 1')
        Local $sHTML = _IEBodyReadText ($oIE)
 Local $hFileOpen = FileOpen("C:\_GESTIONALE_NEW\SPEDIZIONIERI\TRUCKPOOLING_IT\ziofa.txt", $FO_APPEND)
   FileWrite($hFileOpen, $sHTML)
  FileClose($hFileOpen)
MsgBox(0,'1',$sHTML)
                ConsoleWrite($sHTML)

                While 1
                    If  StringInStr($sHTML,'Benvenuto') <> 0 Then
                        ExitLoop
                    EndIf
                Sleep(100)
                WEnd
        If $CmdLine[4] = "Italy" Then ; nazione del mittente

        Else
            Local $oNazioneMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$cmbNazioneMittente")
            Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
                Sleep(10)
            Until IsObj($oNazioneMIT)
            _IEAction($oNazioneMIT, "focus")
            _IEFormElementOptionSelect($oNazioneMIT, $CmdLine[4], 1, "byText")
            Sleep($sleepPass)
        EndIf
        If $CmdLine[5] = "Italia" Then ; nazione del destinatario
        Else
            Local $oNazioneDEST = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$cmbNazioneDestinazione")
            Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
                Sleep(10)
            Until IsObj($oNazioneDEST)
            _IEAction($oNazioneDEST, "focus")
            _IEFormElementOptionSelect($oNazioneDEST, $CmdLine[5], 1, "byText")
        EndIf

        Local $oCittaMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtLocalitaMittente")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oCittaMIT)
        _IEAction($oCittaMIT, "focus")
        _IEAction($oCittaMIT, "Click")
        _IEFormElementSetValue($oCittaMIT, $CmdLine[6] & " - " & $CmdLine[7])


        Local $oCittaDEST = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtLocalitaDestinatario")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oCittaDEST)
        _IEAction($oCittaDEST, "focus")
        _IEAction($oCittaDEST, "Click")
        _IEFormElementSetValue($oCittaDEST, $CmdLine[8] & " - " & $CmdLine[9])

        Local $oColli = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtQuantita1") ;------
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oColli)
        _IEAction($oColli, "focus")
        _IEAction($oColli, "Click")
        _IEFormElementSetValue($oColli, $CmdLine[10])

        Local $oPeso = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtPeso1")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oPeso)
        _IEAction($oPeso, "focus")
        _IEAction($oPeso, "Click")
        _IEFormElementSetValue($oPeso, $CmdLine[11])

        Local $oAltezza = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtAltezza1")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oAltezza)
        _IEAction($oAltezza, "focus")
        _IEAction($oAltezza, "Click")
        _IEFormElementSetValue($oAltezza, $CmdLine[12])

        Local $oLargezza = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtLarghezza1")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oLargezza)
        _IEAction($oLargezza, "focus")
        _IEAction($oLargezza, "Click")
        _IEFormElementSetValue($oLargezza, $CmdLine[13])

        Local $oProfondita = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtProfondita1")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oProfondita)
        _IEAction($oProfondita, "focus")
        _IEAction($oProfondita, "Click")
        _IEFormElementSetValue($oProfondita, $CmdLine[14])


        Local $oBottonQuot = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$btnQuotazioni")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oBottonQuot)
        _IEAction($oBottonQuot, "focus")
        _IEAction($oBottonQuot, "Click")
        _IELoadWait($oIE)

        Local $sScegliSED = IniRead(@ScriptDir & "\config.ini", "configurazione", "key1", "1")
        Select

            Case $sScegliSED = 1
                _Truck_WEB_END()
            Case $sScegliSED <> 1
                Local $iShipmano = MsgBox(4, 'info', 'Vuoi scegliere a mano la spedizione che preferisci ?')
                Select
                    Case $iShipmano = 7
                        _Truck_WEB_END()
                    Case $iShipmano = 6
                        Do
                            Sleep(10)
                            Local $url = _IEPropertyGet($oIE, "locationurl")
                        Until $url = "http://www.truckpooling.it/dettagli-spedizione2.aspx"
                        $iCont_truck = 1
                        _Truck_WEB_END()
                EndSelect
        EndSelect
    EndIf
EndFunc   ;==>_Truckpooling_it_WEB

Func _Help_truck()
    MsgBox(0, "Info", "devi richiamare l'eseguibile con i parametri altrimenti si blocca")
EndFunc   ;==>_Help_truck

Func _Truck_WEB_END()
    Local $sleepPass = 1000

    If $iCont_truck <> 1 Then
        Local $oBottonQuot1 = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$compra1")
        Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
            Sleep(10)
        Until IsObj($oBottonQuot1)
        _IEAction($oBottonQuot1, "focus")
        _IEAction($oBottonQuot1, "Click")
        _IELoadWait($oIE)
    EndIf

    ;-------------------------------------------------------------------------------------------------
    ;----- DETTAGLI SPEDIZIONE -----------------------------------------------------------------------
    Local $oNomeMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtNomeRitiro")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oNomeMIT)
    _IEAction($oNomeMIT, "focus")
    _IEAction($oNomeMIT, "Click")
    _IEFormElementSetValue($oNomeMIT, $CmdLine[15])
    Sleep($sleepPass)

    Local $oCognomeMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtCognomeRitiro")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oCognomeMIT)
    _IEAction($oCognomeMIT, "focus")
    _IEAction($oCognomeMIT, "Click")
    _IEFormElementSetValue($oCognomeMIT, $CmdLine[16])
    Sleep($sleepPass)

    Local $oTelefonoMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtTelefonoRitiro")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oTelefonoMIT)
    _IEAction($oTelefonoMIT, "focus")
    _IEAction($oTelefonoMIT, "Click")
    _IEFormElementSetValue($oTelefonoMIT, $CmdLine[17])
    Sleep($sleepPass)

    Local $oEmailMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtEmailRitiro")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oEmailMIT)
    _IEAction($oEmailMIT, "focus")
    _IEAction($oEmailMIT, "Click")
    _IEFormElementSetValue($oEmailMIT, $CmdLine[18])
    Sleep($sleepPass)

    Local $oAddresMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtIndirizzoRitiro")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oAddresMIT)
    _IEAction($oAddresMIT, "focus")
    _IEAction($oAddresMIT, "Click")
    _IEFormElementSetValue($oAddresMIT, $CmdLine[19])
    ;MsgBox(0,'',$CmdLine[19])
    Sleep($sleepPass)

    Local $oTriangMIT = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$cbxNascondiTriangolazione")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oTriangMIT)
    _IEAction($oTriangMIT, "focus")
    _IEAction($oTriangMIT, "Click")
    ;-------------------------------------------------------------------------------------------------
    ;---- DATI DI CONSEGNA ---------------------------------------------------------------------------
    Local $oNomeDEST = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtNomeDestinatario")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oNomeDEST)
    _IEAction($oNomeDEST, "focus")
    _IEAction($oNomeDEST, "Click")
    _IEFormElementSetValue($oNomeDEST, $CmdLine[20])
    ;Sleep(500)
    Local $oCognomeDEST = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtCognomeDestinatario")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oCognomeDEST)
    _IEAction($oCognomeDEST, "focus")
    _IEAction($oCognomeDEST, "Click")
    _IEFormElementSetValue($oCognomeDEST, $CmdLine[21])
    ;Sleep(500)
    Local $oTelefonoDEST = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtTelefonoDestinatario")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oTelefonoDEST)
    _IEAction($oTelefonoDEST, "focus")
    _IEAction($oTelefonoDEST, "Click")
    _IEFormElementSetValue($oTelefonoDEST, $CmdLine[22])
    ;Sleep(500)
    Local $oAddresDEST = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$txtIndirizzoDestinatario")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oAddresDEST)
    _IEAction($oAddresDEST, "focus")
    _IEAction($oAddresDEST, "Click")
    _IEFormElementSetValue($oAddresDEST, $CmdLine[23])
    ;Sleep(500)
    Local $oBottFinishOrder = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$btnConcludi")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oBottFinishOrder)
    _IEAction($oBottFinishOrder, "focus")
    _IEAction($oBottFinishOrder, "Click")
    _IELoadWait($oIE)
    ;Sleep($sleepButt)
    ;-------------------------------------------------------------------------------------------------
    ;------- PAGAMENTO -------------------------------------------------------------------------------
    ;;MsgBox(0,'','inizio pago')
    Local $oCUtilizzo = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$cbxCondizioniUtilizzoSito")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oCUtilizzo)

    _IEAction($oCUtilizzo, "focus")
    _IEAction($oCUtilizzo, "Click")
    ;Sleep(1000)
    Local $oCPrivacy = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$cbxPrivacy")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oCPrivacy)
    _IEAction($oCPrivacy, "focus")
    _IEAction($oCPrivacy, "Click")
    ;Sleep(1000)
    Local $oCTrasporto = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$cbxCondizioniUtilizzoTrasporto")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oCTrasporto)
    _IEAction($oCTrasporto, "focus")
    _IEAction($oCTrasporto, "Click")
    ;Sleep(1000)
    Local $oCPayPal = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$grpPagamento")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oCPayPal)
    _IEAction($oCPayPal, "focus")
    _IEAction($oCPayPal, "Click")
    ;Sleep(1000)
    Local $oButtSpedisci = _IEGetObjByName($oIE, "ctl00$ContentPlaceHolder1$btnSpedisci")
    Do ; stay here untill the $oCUtilizzo object is ready (untill is an obj)
        Sleep(10)
    Until IsObj($oButtSpedisci)
    _IEAction($oButtSpedisci, "focus")
    _IEAction($oButtSpedisci, "Click")
    ;Sleep($sleepButt)
    ;-------------------------------------------------------------------------------------------------
EndFunc   ;==>_Truck_WEB_END

anybody can help me??  thankz

 

 

Share this post


Link to post
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

×