PedroFonseca

logon at web form 4 times a day

8 posts in this topic

Hello,

Thanks in advance, i'm new at programming and i'm learning to use autoit.

This is the script i have:

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

$Form1 = GUICreate(":::test:::", 295, 279, 192, 124)

$Nome = GUICtrlCreateInput("nome", 32, 64, 113, 21)
$Pass = GUICtrlCreateInput("pass", 152, 64, 113, 21)

$Hora01 = GUICtrlCreateInput("HH:MM", 88, 136, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Hora02 = GUICtrlCreateInput("HH:MM", 88, 168, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Hora03 = GUICtrlCreateInput("HH:MM", 88, 200, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$Hora04 = GUICtrlCreateInput("HH:MM", 88, 232, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))

$Label1 = GUICtrlCreateLabel("Name", 32, 40, 32, 17)
$Label2 = GUICtrlCreateLabel("Password", 152, 40, 50, 17)
$Label3 = GUICtrlCreateLabel("Time 01", 24, 136, 42, 17)
$Label4 = GUICtrlCreateLabel("Time 02", 24, 168, 42, 17)
$Label5 = GUICtrlCreateLabel("Time 03", 24, 200, 42, 17)
$Label6 = GUICtrlCreateLabel("Time 04", 24, 232, 42, 17)

$Group1 = GUICtrlCreateGroup("Name and Password", 16, 24, 265, 89)
$Group2 = GUICtrlCreateGroup("Time", 16, 120, 177, 145)

$Marcar = GUICtrlCreateButton("INICIATE", 200, 120, 81, 145)
GUISetState(@SW_SHOW)


While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit

        Case $Marcar
             signin ()
    EndSwitch
WEnd

Func signin ()

Local $oIE = _IECreate("https://..website form...com")
Local $oForm = _IEGetObjByName($oIE, "logonForm")
Local $username= _IEGetObjByName($oIE, "username")
Local $password= _IEGetObjByName($oIE, "password")
_IEFormElementSetValue ($username, GUICtrlRead($Nome) )
_IEFormElementSetValue ($password, GUICtrlRead($Pass) )
_IEFormSubmit($oForm)

EndFunc

I need to login into a website 4 times a day on a specific time (inputbox) and i'm struggling with the code, can you  help me?

Thanks again.

Share this post


Link to post
Share on other sites



Just curious, why do you need to log in 4 times a day at a specific time?


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Try:

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

;~ Array to store your time and date
Global $aHora[5][2]
$aHora[0][0] = _NowTime()
$aHora[0][1] = _NowDate()
$Form1 = GUICreate(":::test:::", 295, 279, 192, 124)

$Nome = GUICtrlCreateInput("nome", 32, 64, 113, 21)
$Pass = GUICtrlCreateInput("pass", 152, 64, 113, 21)

$aHora01 = GUICtrlCreateInput("HH:MM", 88, 136, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$aHora02 = GUICtrlCreateInput("HH:MM", 88, 168, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$aHora03 = GUICtrlCreateInput("HH:MM", 88, 200, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))
$aHora04 = GUICtrlCreateInput("HH:MM", 88, 232, 81, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER))

$Label1 = GUICtrlCreateLabel("Name", 32, 40, 32, 17)
$Label2 = GUICtrlCreateLabel("Password", 152, 40, 50, 17)
$Label3 = GUICtrlCreateLabel("Time 01", 24, 136, 42, 17)
$Label4 = GUICtrlCreateLabel("Time 02", 24, 168, 42, 17)
$Label5 = GUICtrlCreateLabel("Time 03", 24, 200, 42, 17)
$Label6 = GUICtrlCreateLabel("Time 04", 24, 232, 42, 17)

$Group1 = GUICtrlCreateGroup("Name and Password", 16, 24, 265, 89)
$Group2 = GUICtrlCreateGroup("Time", 16, 120, 177, 145)

$Marcar = GUICtrlCreateButton("INICIATE", 200, 120, 81, 145)
GUISetState(@SW_SHOW)

;~ Check the Time every 250 ms
AdlibRegister("CheckTime")

While 1

    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Marcar
            $aHora[1][0] = GUICtrlRead($aHora01)
            $aHora[2][0] = GUICtrlRead($aHora01)
            $aHora[3][0] = GUICtrlRead($aHora01)
            $aHora[4][0] = GUICtrlRead($aHora01)
            signin ()
    EndSwitch
WEnd

Func CheckTime()
    ;~ Check to see if the Date has changed to reset the time date values to blank
    If $aHora[0][1] <> _NowDate() Then
        $aHora[0][1] = _NowDate()
        $aHora[1][1] = ""
        $aHora[2][1] = ""
        $aHora[3][1] = ""
        $aHora[4][1] = ""
    EndIf
    ;~ Check Hour:Min equals Hora[x][0] Time
    ;~ Check Hora[x][1] is blank (not run)
    ;~  True  - Sigin
    ;~        - Set Hora[x][1] to Current Date
    ;~  False - Sigin already iniciated, return.
    Local $sHora = @HOUR & ":" & @min
    Switch $sHora
        Case $aHora[1][0]
            If $aHora[1][1] = "" Then
                signin()
                $aHora[1][1] = _NowDate()
            EndIf
        Case $aHora[2][0]
            If $aHora[2][1] = "" Then
                signin()
                $aHora[2][1] = _NowDate()
            EndIf
        Case $aHora[3][0]
            If $aHora[3][1] = "" Then
                signin()
                $aHora[3][1] = _NowDate()
            EndIf
        Case $aHora[4][0]
            If $aHora[4][1] = "" Then
                signin()
                $aHora[4][1] = _NowDate()
            EndIf
    EndSwitch
EndFunc

Func signin ()

Local $oIE = _IECreate("https://..website form...com")
Local $oForm = _IEGetObjByName($oIE, "logonForm")
Local $username= _IEGetObjByName($oIE, "username")
Local $password= _IEGetObjByName($oIE, "password")
_IEFormElementSetValue ($username, GUICtrlRead($Nome) )
_IEFormElementSetValue ($password, GUICtrlRead($Pass) )
_IEFormSubmit($oForm)

EndFunc

 

Share this post


Link to post
Share on other sites

@Subz, you have been here long enough to know that when a Moderator asks a question, it is best to wait until the question is answered before you go offering suggestions. It might just be that he is asking questions to determine the legitimacy of the post (like maybe bullet points two and three in the rules).


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

@JLogan3o13 Apologies didn't realise your question was regarding the legitimacy of his post, just thought it was a general question.  If you want I can remove the post.

Share this post


Link to post
Share on other sites

No, just please be more aware in the future.


√-1 2^3 ∑ π, and it was delicious!

Share this post


Link to post
Share on other sites

Hello guys,

Sorry Subz i didnt mean to get you in trouble and thank you for your help, JLogan3o1 i ask for help because im a moderator in a Adult website Forum and i need to login at specific time to check certain user activities. This script is just to automate my login, just that... i'm looking forward to learn this language better. Can i post further questions?

 

 

Share this post


Link to post
Share on other sites

#8 ·  Posted (edited)

@PedroFonseca our main concern is that threads follow the forum rules; when it comes to automation websites particularly bullet points 2 and 3 in the rules. As long as you familiarize yourself with these rules, and keep from stepping over them, I am fine with the thread continuing. Of note, as you're dealing with an adult website, please no links to the site.

P.S. Subz is not in trouble; he is one of many folks that do a great job helping on the forum. Just a friendly reminder :)

 

Edited by JLogan3o13

√-1 2^3 ∑ π, and it was delicious!

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