Jump to content

I have an error in my script, could you help me?


Recommended Posts

Quote
#include<GUIConstants.au3>
#include<MsgBoxConstants.au3>
#include<File.au3>
#include <ScreenCapture.au3>


;RIO CLARO

ShellExecute ("https://portal.gissonline.com.br/")
WinWaitActive("Gissonline - Google Chrome")



ChecarJanela()



Func ChecarJanela()
    $x = 2
    $y = 0
    $largura = 1053
    $altura = 816



    Local $pos  =  WinGetPos("Gissonline - Google Chrome")
    ;MsgBox($MB_SYSTEMMODAL, "","X:" & $pos[0] & "Y:" & $pos[1] & "Largura:" & $pos[2] & "Altura:" & $pos[3])

    if @error =0 Then



    If $pos [0] == $x And $pos [1] == $y And $pos [2] == $largura And $pos [3] == $altura Then

    Else

        Ajustarjanela($x,$y,$largura,$altura)


    EndIf

    EndIf



EndFunc






Func Ajustarjanela ($x,$y,$largura,$altura)

    WinMove("Gissonline - Google Chrome","",$x,$y,$largura,$altura)
    ChecarJanela()

EndFunc

Sleep(1000)
MouseWheel ($MOUSE_WHEEL_DOWN,2 )
Sleep(1500)
MouseClick("primary",188,652,1,10)
Sleep(1500)
MouseClick("primary",434,454,2,10)
Sleep(500)
Send("login")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("password")
MouseClick("primary",533,564,1,10)
WinWaitActive("https://wwwx.gissonline.com.br/interna/default.cfm - Google Chrome")
MouseClick("primary",370,127,1,10)
PixeldeErro()




Func IniciatBot()
    while 1
        PixeldeErro()
    WEnd
EndFunc




Func PixeldeErro()


    while 1
        $pixel = PixelSearch(0,0,297,110,0xECF2EE)

        If not @error Then
        ;PAGINA COM ERRO
        WinWaitActive("Operação Indisponível - Google Chrome")
        _ScreenCapture_Capture(@MyDocumentsDir & "\Erro_Rio_CLaro.jpg",2,0,1173,816)
        ShellExecute("C:\Users\robert.santana\OneDrive\Área de Trabalho\Erros do Gissonline.txt")
        Sleep(500)
        Send("Erro na aba de tomador, Rio Claro. {F5}" & @CRLF)
        Sleep(5000)
        ExitLoop




        Else
        ;SEM  ERRO
        Sleep(1000)
        WinClose("https://wwwx.gissonline.com.br/interna/default.cfm - Google Chrome")
        MsgBox($MB_ICONINFORMATION, "Pagina sem erro", "Tudo Certo!")
        ExitLoop

        EndIf

    WEnd

EndFunc

 

Here is my script, I need it to recognize an error on the page and let me know, otherwise show me a message that everything is ok.
however, the error appears on the page, but even so the message appears that everything is ok.
sorry for the english, i'm new to this and new to autoit.

Link to comment
Share on other sites

Quote
#include<GUIConstants.au3>
#include<MsgBoxConstants.au3>
#include<File.au3>
#include <ScreenCapture.au3>


;RIO CLARO

ShellExecute ("https://portal.gissonline.com.br/")
WinWaitActive("Gissonline - Google Chrome")



ChecarJanela()



Func ChecarJanela()
    $x = 2
    $y = 0
    $largura = 1053
    $altura = 816



    Local $pos  =  WinGetPos("Gissonline - Google Chrome")
    ;MsgBox($MB_SYSTEMMODAL, "","X:" & $pos[0] & "Y:" & $pos[1] & "Largura:" & $pos[2] & "Altura:" & $pos[3])

    if @error =0 Then



    If $pos [0] == $x And $pos [1] == $y And $pos [2] == $largura And $pos [3] == $altura Then

    Else

        Ajustarjanela($x,$y,$largura,$altura)


    EndIf

    EndIf



EndFunc






Func Ajustarjanela ($x,$y,$largura,$altura)

    WinMove("Gissonline - Google Chrome","",$x,$y,$largura,$altura)
    ChecarJanela()

EndFunc

Sleep(1000)
MouseWheel ($MOUSE_WHEEL_DOWN,2 )
Sleep(1500)
MouseClick("primary",188,652,1,10)
Sleep(1500)
MouseClick("primary",434,454,2,10)
Sleep(500)
Send("login")
Sleep(500)
Send("{TAB}")
Sleep(500)
Send("password")
MouseClick("primary",533,564,1,10)
WinWaitActive("https://wwwx.gissonline.com.br/interna/default.cfm - Google Chrome")
MouseClick("primary",370,127,1,10)
PixeldeErro()




Func IniciatBot()
    while 1
        PixeldeErro()
    WEnd
EndFunc




Func PixeldeErro()


    while 1
        $pixel = PixelSearch(0,0,297,110,0xECF2EE)

        If not @error Then
        ;PAGINA COM ERRO
        WinWaitActive("Operação Indisponível - Google Chrome")
        _ScreenCapture_Capture(@MyDocumentsDir & "\Erro_Rio_CLaro.jpg",2,0,1173,816)
        ShellExecute("C:\Users\robert.santana\OneDrive\Área de Trabalho\Erros do Gissonline.txt")
        Sleep(500)
        Send("Erro na aba de tomador, Rio Claro. {F5}" & @CRLF)
        Sleep(5000)
        ExitLoop




        Else
        ;SEM  ERRO
        Sleep(1000)
        WinClose("https://wwwx.gissonline.com.br/interna/default.cfm - Google Chrome")
        MsgBox($MB_ICONINFORMATION, "Pagina sem erro", "Tudo Certo!")
        ExitLoop

        EndIf

    WEnd

EndFunc

Here is my script, I need it to recognize an error on the page and let me know, otherwise show me a message that everything is ok.
however, the error appears on the page, but even so the message appears that everything is ok.
sorry for the english, i'm new to this and new to autoit.

 

Link to comment
Share on other sites

  • Moderators

robertsantana,

Point 1: Why post exactly the same script as last week? I have merged the 2 - please do not do it again.

Point 2: When you post scripts, please use code tags - see here how to do it.

Thanks in advance for your cooperation.

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

As i'm (atm) not interested in browser automation (and my main browser is iron and not chrome), i do not know if there is an udf which can do this automatically ...

 

But here is an idea, something that you may want to try out:

 

Instead of doing pixel search for the error text, you can activate the window, then send "ctrl a" keys to select all text, then send "ctrl c" to copy the text to the clipboard.

After that you can read out the clipboard content in a variable and check if it contains the error message. 

Then you can proceed in your script or stop it.

That's how i would approach it.

Edited by Dan_555

Some of my script sourcecode

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