Jump to content

Why my script does not work?


Recommended Posts

Hello, I try a problem with my script for simple login, I added a script of a button, that when the button is clicked, open my site

The script is right, the problem and that it does not work

Look Script :

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>;
#include <EditConstants.au3>



$Form1 = GUICreate("Login", 400, 250, -1, -1) ; begining of Login
$PASSWORD = GUICtrlCreateInput("", 65, 167, 220, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 200, 220, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 280, 220, 75, 25, 0)
$passwordlabel = GUICtrlCreateLabel("Password:", 8, 172, 50, 17)
$usernamelabel = GUICtrlCreateLabel("Username:", 8, 143, 52, 17)
$USERNAME = GUICtrlCreateInput("", 65, 144, 220, 21)

Global $url = "http://forumgohc.freehostia.com/forum/index.php?action=register" ; here button that not work
$Forum = GUICtrlCreateButton("Cadastre-se no Forum",10,220,110,25)
Guictrlsetonevent(-1,"_website")


GUICtrlCreateGroup('',10,2,380,100)
        GUICtrlCreateLabel('Terms of use of this Software',30,10,340,18)
        GUICtrlSetColor(-1, 0x0012FF)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,28,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,46,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,64,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,82,340,18)
        GUICtrlSetFont(-1,12,400)
    GUICtrlCreateGroup('',-99,-99,1,1)
    GUICtrlSetBkColor(-1,0x000000)
GUISetState(@SW_SHOW)


While 1
    $MSG = GUIGetMsg()
    Switch $MSG
    Case $ButtonOk
        If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) = 1 Then
            GUIDelete($Form1)
            MsgBox(-1,"Logado com Sucesso","Login Succ..")
            RunP()


        Else
            MsgBox(-1,"Error"," Username ou Senha está incorreto, Tente denovo")
        EndIf
    Case -3
        Exit
    Case $ButtonCancel
        Exit
    EndSwitch
WEnd

Func _website() ; part of script for run
ShellExecute($url)
Endfunc

Func VerifyLogin($USERNAME,$PASSWORD)
    If $USERNAME = "your username here" And $PASSWORD = "your pass here" Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc ; End login



Func Runp()

    ;Your Code begining here
EndFunc

Func onautoitexit()
   Exit
EndFunc  ;==>onautoitexit

Awaiting Answers

Edited by 10031992

-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

Link to comment
Share on other sites

In the beginning of your script your using GUIGetMsg() to verify the username/password which is using Opt("GUIOnEventMode", 0)..

But for the website button your trying to use Opt("GUIOnEventMode", 1)..

You can't have both Opt("GUIOnEventMode", 0) and Opt("GUIOnEventMode", 1) running at the same time.

It needs to be one mode or the other...

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>;
#include <EditConstants.au3>



$Form1 = GUICreate("Login", 400, 250, -1, -1) ; begining of Login
$PASSWORD = GUICtrlCreateInput("", 65, 167, 220, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 200, 220, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 280, 220, 75, 25, 0)
$passwordlabel = GUICtrlCreateLabel("Password:", 8, 172, 50, 17)
$usernamelabel = GUICtrlCreateLabel("Username:", 8, 143, 52, 17)
$USERNAME = GUICtrlCreateInput("", 65, 144, 220, 21)

Global $url = "http://forumgohc.freehostia.com/forum/index.php?action=register" ; here button that not work
$Forum = GUICtrlCreateButton("Cadastre-se no Forum",10,220,110,25)
;~ Guictrlsetonevent(-1,"_website")


GUICtrlCreateGroup('',10,2,380,100)
        GUICtrlCreateLabel('Terms of use of this Software',30,10,340,18)
        GUICtrlSetColor(-1, 0x0012FF)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,28,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,46,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,64,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,82,340,18)
        GUICtrlSetFont(-1,12,400)
    GUICtrlCreateGroup('',-99,-99,1,1)
    GUICtrlSetBkColor(-1,0x000000)
GUISetState(@SW_SHOW)


While 1
    $MSG = GUIGetMsg()
    Switch $MSG
    Case $ButtonOk
        If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) = 1 Then
            GUIDelete($Form1)
            MsgBox(-1,"Logado com Sucesso","Login Succ..")
            RunP()


        Else
            MsgBox(-1,"Error"," Username ou Senha está incorreto, Tente denovo")
        EndIf
    Case -3, $ButtonCancel
        Exit
    Case $Forum
        _website()
    EndSwitch
WEnd

Func _website() ; part of script for run
ShellExecute($url)
Endfunc

Func VerifyLogin($USERNAME,$PASSWORD)
    If $USERNAME = "your username here" And $PASSWORD = "your pass here" Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc ; End login



Func Runp()

    ;Your Code begining here
EndFunc
Link to comment
Share on other sites

Thanks for that I did not know

Now I have a question, you know I mean, how do I get the usernames and passwords, are equal to the user of my forum, so they need only register in the forum to use the program

I use the inetget, so I can change the password and username

Look

Func VerifyLogin($USERNAME,$PASSWORD)
local $x = 1
Do
inetget("http://gohc.freehostia.com/Login.txt",@systemdir & "/Login.txt") ; Link old
$login = filereadline(@systemdir & "/Login.txt",$x)
$string = stringsplit($login,"|")
if $string[1] = $username and $string[2] = $password then
return 1
exitloop
Else
$x = $x + 1
Endif
if $login = "" then
return 0
exitloop
endif
until $x = $x + 1
EndFunc

-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

Link to comment
Share on other sites

Hi again,

You can just loop through the strings in the login.txt and compare them to the user/pass fields in your gui..

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>;
#include <EditConstants.au3>
#include <Array.au3>


$Form1 = GUICreate("Login", 400, 250, -1, -1) ; begining of Login
$PASSWORD = GUICtrlCreateInput("", 65, 167, 220, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 200, 220, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 280, 220, 75, 25, 0)
$passwordlabel = GUICtrlCreateLabel("Password:", 8, 172, 50, 17)
$usernamelabel = GUICtrlCreateLabel("Username:", 8, 143, 52, 17)
$USERNAME = GUICtrlCreateInput("", 65, 144, 220, 21)

Global $url = "http://forumgohc.freehostia.com/forum/index.php?action=register" ; here button that not work
$Forum = GUICtrlCreateButton("Cadastre-se no Forum",10,220,110,25)
;~ Guictrlsetonevent(-1,"_website")


GUICtrlCreateGroup('',10,2,380,100)
        GUICtrlCreateLabel('Terms of use of this Software',30,10,340,18)
        GUICtrlSetColor(-1, 0x0012FF)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,28,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,46,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,64,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,82,340,18)
        GUICtrlSetFont(-1,12,400)
    GUICtrlCreateGroup('',-99,-99,1,1)
    GUICtrlSetBkColor(-1,0x000000)
GUISetState(@SW_SHOW)


While 1
    $MSG = GUIGetMsg()
    Switch $MSG
    Case $ButtonOk
        If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) Then
;~             GUIDelete($Form1)
            MsgBox(-1,"Logado com Sucesso","Login Succ..")
            RunP()
        Else
            MsgBox(-1,"Error"," Username ou Senha está incorreto, Tente denovo")
        EndIf
    Case -3, $ButtonCancel
        Exit
    Case $Forum
        _website()
    EndSwitch
WEnd

Func _website() ; part of script for run
ShellExecute($url)
Endfunc

Func VerifyLogin($sName, $sPass)
    Local $TMP, $IG, $aTmp, $aUP
    $TMP = @TempDir & "\Login.txt"
    $IG = InetGet("http://gohc.freehostia.com/Login.txt", $TMP, 1, 0)
    If $IG And FileExists($TMP) Then
        $aTmp = StringSplit(FileRead($TMP), @LF , 2)
        For $i = 0 To UBound($aTmp) -1
            $aUP = StringSplit($aTmp[$i], "|", 2) 
            If $aUP[0] == $sName And $aUP[1] == $sPass Then Return FileDelete($TMP)
        Next
        FileDelete($TMP)
        Return 0
    Else
        Return 0
    EndIf
EndFunc ; End login

You might want to encrypt the login.txt file so a novice user doesn't see all the passwords and usernames.

decrypt the login.txt as your program reads the login.txt..

Suggestions:

Dumping files in a persons system directory is not polite to the end user who uses your program..

Maybe dl the login.txt to a temp directory or even in the users application data directory.

Cheers

Link to comment
Share on other sites

Hi again,

You can just loop through the strings in the login.txt and compare them to the user/pass fields in your gui..

#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>;
#include <EditConstants.au3>
#include <Array.au3>


$Form1 = GUICreate("Login", 400, 250, -1, -1) ; begining of Login
$PASSWORD = GUICtrlCreateInput("", 65, 167, 220, 21, BitOR($ES_PASSWORD,$ES_AUTOHSCROLL))
$ButtonOk = GUICtrlCreateButton("&OK", 200, 220, 75, 25, 0)
$ButtonCancel = GUICtrlCreateButton("&Cancel", 280, 220, 75, 25, 0)
$passwordlabel = GUICtrlCreateLabel("Password:", 8, 172, 50, 17)
$usernamelabel = GUICtrlCreateLabel("Username:", 8, 143, 52, 17)
$USERNAME = GUICtrlCreateInput("", 65, 144, 220, 21)

Global $url = "http://forumgohc.freehostia.com/forum/index.php?action=register" ; here button that not work
$Forum = GUICtrlCreateButton("Cadastre-se no Forum",10,220,110,25)
;~ Guictrlsetonevent(-1,"_website")


GUICtrlCreateGroup('',10,2,380,100)
        GUICtrlCreateLabel('Terms of use of this Software',30,10,340,18)
        GUICtrlSetColor(-1, 0x0012FF)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,28,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,46,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,64,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,82,340,18)
        GUICtrlSetFont(-1,12,400)
    GUICtrlCreateGroup('',-99,-99,1,1)
    GUICtrlSetBkColor(-1,0x000000)
GUISetState(@SW_SHOW)


While 1
    $MSG = GUIGetMsg()
    Switch $MSG
    Case $ButtonOk
        If VerifyLogin(GUICtrlRead($USERNAME),GUICtrlRead($PASSWORD)) Then
;~             GUIDelete($Form1)
            MsgBox(-1,"Logado com Sucesso","Login Succ..")
            RunP()
        Else
            MsgBox(-1,"Error"," Username ou Senha está incorreto, Tente denovo")
        EndIf
    Case -3, $ButtonCancel
        Exit
    Case $Forum
        _website()
    EndSwitch
WEnd

Func _website() ; part of script for run
ShellExecute($url)
Endfunc

Func VerifyLogin($sName, $sPass)
    Local $TMP, $IG, $aTmp, $aUP
    $TMP = @TempDir & "\Login.txt"
    $IG = InetGet("http://gohc.freehostia.com/Login.txt", $TMP, 1, 0)
    If $IG And FileExists($TMP) Then
        $aTmp = StringSplit(FileRead($TMP), @LF , 2)
        For $i = 0 To UBound($aTmp) -1
            $aUP = StringSplit($aTmp[$i], "|", 2) 
            If $aUP[0] == $sName And $aUP[1] == $sPass Then Return FileDelete($TMP)
        Next
        FileDelete($TMP)
        Return 0
    Else
        Return 0
    EndIf
EndFunc ; End login

You might want to encrypt the login.txt file so a novice user doesn't see all the passwords and usernames.

decrypt the login.txt as your program reads the login.txt..

Suggestions:

Dumping files in a persons system directory is not polite to the end user who uses your program..

Maybe dl the login.txt to a temp directory or even in the users application data directory.

Cheers

That I do not understand, you told me to buy, with what?

with this?

http://forumgohc.freehostia.com/forum/index.php?action=mlist

-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

Link to comment
Share on other sites

That I do not understand, you told me to buy, with what?

with this?

http://forumgohc.freehostia.com/forum/index.php?action=mlist

I do not encrypt I will not allow any person has access this file, only admins

permi.. 600

-------------------------------------------------------------------------------------------------------------------------------------------- [center][/center][center]Autoit Support Forum in Portuguese | AutoitBrasil.com[/center] [sub]My Script :[/sub]Simples Login for Program

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