Jump to content

simple login using ini


 Share

Recommended Posts

dude i have searched 4 hours u dont understand all the ones i find dont work with the gui i have with the gng i have spent all day and niht on here dont say i havnt searched 4 fuck sake my life is gettinng fucked up cos i spend all my time on here not going to work just trying to work out things

Link to comment
Share on other sites

I just help another member in another topic for this

You simply use my script to login

There you set a username and password

But we can modify it by creating a. Txt in internet

#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)
GUICtrlCreateGroup('',10,2,380,100)
        GUICtrlCreateLabel('Terms of use of this Software',30,10,340,18)
        GUICtrlSetColor(-1, 0x0012FF)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('To use this software to be Registered in Forum',30,28,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,46,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('To open the program',30,64,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('Team gOHc Thank you for your choice',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 VerifyLogin($USERNAME,$PASSWORD)
    If $USERNAME = "your user 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

This is for modific in internet

Func VerifyLogin($USERNAME,$PASSWORD)
local $x = 1
Do
inetget("http://yoursite.com/login.txt",@systemdir & "/login.txt")
$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

Simply create a .Txt with the username and password

user|pass1
user2|pass2

I hope I have helped

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

how to add it to this script

; Special thanks to GaryFrost for updating this to work with AutoIt v3.2.12.0!

#NoTrayIcon
#include <GDIPlus.au3>; this is where the magic happens, people
#include <GuiComboBox.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
Opt("MustDeclareVars", 0)

Global Const $AC_SRC_ALPHA = 1
;~ Global Const $ULW_ALPHA         = 2
Global $old_string = "", $runthis = ""
Global $launchDir = @DesktopDir

; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\LaunchySkin.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

; Extract image width and height from PNG
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)

; Create layered window
$GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
WinSetOnTop($GUI, "", 1)
;fade in png background
For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImage, $i)
Next


; create child MDI gui window to hold controls
; this part could use some work - there is some flicker sometimes...
$controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)

; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)

; just a text label
GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter", 50, 12, 140, 50)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)

; combo box listing all items on desktop
$Combo = GUICtrlCreateCombo("", 210, 12, 250, -1)
GUICtrlSetFont($Combo, 12)


; set default button for Enter key activation - renders outside GUI window
$goButton = GUICtrlCreateButton("Go", $width, $height, 10, 10, $BS_DEFPUSHBUTTON)

GUISetState()

; get list of files on desktop, show in combobox
$aFileList = _FileListToArray($launchDir)
_ArraySort($aFileList, 0, 1)
$FileList = _ArrayToString($aFileList, "|", 1)
GUICtrlSetData($Combo, $FileList)

AdlibEnable("GoAutoComplete", 1000); combo autocomplete every message loop = often incorrect
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $goButton
            $runthis = GUICtrlRead($Combo)
            ExitLoop
    EndSelect
WEnd
AdlibDisable()



If $runthis <> "" Then
    If FileExists($launchDir & "\" & $runthis) Then
        Beep(1000, 50)
        Beep(2000, 50)
        _ShellExecute($runthis, "", $launchDir)
    EndIf
EndIf

GUIDelete($controlGui)
;fade out png background
For $i = 255 To 0 Step -10
    SetBitmap($GUI, $hImage, $i)
Next

; Release resources
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()



Func GoAutoComplete()
    _GUICtrlComboBox_AutoComplete($Combo)
EndFunc   ;==>GoAutoComplete

; ====================================================================================================

; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

; ====================================================================================================

; SetBitMap
; ====================================================================================================

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap


; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself.
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
    $aRet = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "", _
            "string", $sCmd, _
            "string", $sArg, _
            "string", $sFolder, _
            "int", $rState)
    If @error Then Return 0

    $RetVal = $aRet[0]
    If $RetVal > 32 Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>_ShellExecute

post-51655-12502647709611_thumb.png

post-51655-12502647854739_thumb.gif

Edited by MrParo
Link to comment
Share on other sites

  • Developers

i get heaps of errors when i add this 1 is when u click ok when i havnt put in a password ans user name.

Its probably the problem on line 5. (If you want a more serious reply you have to start being serious in this thread.)

Do you seriously think anybody can help you after writing you "get errors" and not telling what it is and what script you are running?

Edited by Jos

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

ok well 1st off im sorry.

these r my probs when i type in the right lonin name and password.

I get Error Line 190

If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION

If ($hWnd = ^ERROR

Error: Variable used without being declared.

2nd prob if i click ok and dont enter a user name or pass word i get this error

Line 67

if $string[1] = $username and $string[2] = $password then

if $string[1] = $username and ^ERROR

Error: Array variable has incorrect number of subscripts or subscript dimension rage exceeded.

is there any1 that can please help me? here is the script im using..

; Special thanks to GaryFrost for updating this to work with AutoIt v3.2.12.0!

#NoTrayIcon
#include <GDIPlus.au3>; this is where the magic happens, people
#include <GuiComboBox.au3>
#include <File.au3>
#include <Array.au3>
#include <WindowsConstants.au3>
#include <GuiConstantsEx.au3>
#include <ButtonConstants.au3>
#include <ButtonConstants.au3>
#include <GUIConstantsEx.au3>
#include <EditConstants.au3>
Opt("MustDeclareVars", 0)



$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)
GUICtrlCreateGroup('',10,2,380,100)
        GUICtrlCreateLabel('Terms of use of this Software',30,10,340,18)
        GUICtrlSetColor(-1, 0x0012FF)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('To use this software to be Registered in Forum',30,28,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('',30,46,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('To open the program',30,64,340,18)
        GUICtrlSetFont(-1,12,400)
        GUICtrlCreateLabel('Team gOHc Thank you for your choice',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 VerifyLogin($USERNAME,$PASSWORD)
local $x = 1
Do
inetget("http://mysite.com/UserName_Password.txt",@systemdir & "/UserName_Password.txt") ;i changed my reall site to mysite to be safe
$login = filereadline(@systemdir & "/UserName_Password.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



Func Runp()
Global Const $AC_SRC_ALPHA = 1
;~ Global Const $ULW_ALPHA         = 2
Global $old_string = "", $runthis = ""
Global $launchDir = @DesktopDir

; Load PNG file as GDI bitmap
_GDIPlus_Startup()
$pngSrc = @ScriptDir & "\LaunchySkin.png"
$hImage = _GDIPlus_ImageLoadFromFile($pngSrc)

; Extract image width and height from PNG
$width = _GDIPlus_ImageGetWidth($hImage)
$height = _GDIPlus_ImageGetHeight($hImage)

; Create layered window
$GUI = GUICreate("lod3n launcher", $width, $height, -1, -1, $WS_POPUP, $WS_EX_LAYERED)
SetBitmap($GUI, $hImage, 0)
; Register notification messages
GUIRegisterMsg($WM_NCHITTEST, "WM_NCHITTEST")
GUISetState()
WinSetOnTop($GUI, "", 1)
;fade in png background
For $i = 0 To 255 Step 10
    SetBitmap($GUI, $hImage, $i)
Next


; create child MDI gui window to hold controls
; this part could use some work - there is some flicker sometimes...
$controlGui = GUICreate("ControlGUI", $width, $height, 0, 0, $WS_POPUP, BitOR($WS_EX_LAYERED, $WS_EX_MDICHILD), $GUI)

; child window transparency is required to accomplish the full effect, so $WS_EX_LAYERED above, and
; I think the way this works is the transparent window color is based on the image you set here:
GUICtrlCreatePic(@ScriptDir & "\grey.gif", 0, 0, $width, $height)
GUICtrlSetState(-1, $GUI_DISABLE)

; just a text label
GUICtrlCreateLabel("Type the name of a file on your desktop and press Enter", 50, 12, 140, 50)
GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT)
GUICtrlSetColor(-1, 0xFFFFFF)

; combo box listing all items on desktop
$Combo = GUICtrlCreateCombo("", 210, 12, 250, -1)
GUICtrlSetFont($Combo, 12)


; set default button for Enter key activation - renders outside GUI window
$goButton = GUICtrlCreateButton("Go", $width, $height, 10, 10, $BS_DEFPUSHBUTTON)

GUISetState()

; get list of files on desktop, show in combobox
$aFileList = _FileListToArray($launchDir)
_ArraySort($aFileList, 0, 1)
$FileList = _ArrayToString($aFileList, "|", 1)
GUICtrlSetData($Combo, $FileList)

AdlibEnable("GoAutoComplete", 1000); combo autocomplete every message loop = often incorrect
While 1
    $msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case $msg = $goButton
            $runthis = GUICtrlRead($Combo)
            ExitLoop
    EndSelect
WEnd
AdlibDisable()



If $runthis <> "" Then
    If FileExists($launchDir & "\" & $runthis) Then
        Beep(1000, 50)
        Beep(2000, 50)
        _ShellExecute($runthis, "", $launchDir)
    EndIf
EndIf

GUIDelete($controlGui)
;fade out png background
For $i = 255 To 0 Step -10
    SetBitmap($GUI, $hImage, $i)
Next

; Release resources
_WinAPI_DeleteObject($hImage)
_GDIPlus_Shutdown()
EndFunc

Func onautoitexit()
   Exit
EndFunc ;==>onautoitexit



Func GoAutoComplete()
    _GUICtrlComboBox_AutoComplete($Combo)
EndFunc   ;==>GoAutoComplete

; ====================================================================================================

; Handle the WM_NCHITTEST for the layered window so it can be dragged by clicking anywhere on the image.
; ====================================================================================================

Func WM_NCHITTEST($hWnd, $iMsg, $iwParam, $ilParam)
    If ($hWnd = $GUI) And ($iMsg = $WM_NCHITTEST) Then Return $HTCAPTION
EndFunc   ;==>WM_NCHITTEST

; ====================================================================================================

; SetBitMap
; ====================================================================================================

Func SetBitmap($hGUI, $hImage, $iOpacity)
    Local $hScrDC, $hMemDC, $hBitmap, $hOld, $pSize, $tSize, $pSource, $tSource, $pBlend, $tBlend

    $hScrDC = _WinAPI_GetDC(0)
    $hMemDC = _WinAPI_CreateCompatibleDC($hScrDC)
    $hBitmap = _GDIPlus_BitmapCreateHBITMAPFromBitmap($hImage)
    $hOld = _WinAPI_SelectObject($hMemDC, $hBitmap)
    $tSize = DllStructCreate($tagSIZE)
    $pSize = DllStructGetPtr($tSize)
    DllStructSetData($tSize, "X", _GDIPlus_ImageGetWidth($hImage))
    DllStructSetData($tSize, "Y", _GDIPlus_ImageGetHeight($hImage))
    $tSource = DllStructCreate($tagPOINT)
    $pSource = DllStructGetPtr($tSource)
    $tBlend = DllStructCreate($tagBLENDFUNCTION)
    $pBlend = DllStructGetPtr($tBlend)
    DllStructSetData($tBlend, "Alpha", $iOpacity)
    DllStructSetData($tBlend, "Format", $AC_SRC_ALPHA)
    _WinAPI_UpdateLayeredWindow($hGUI, $hScrDC, 0, $pSize, $hMemDC, $pSource, 0, $pBlend, $ULW_ALPHA)
    _WinAPI_ReleaseDC(0, $hScrDC)
    _WinAPI_SelectObject($hMemDC, $hOld)
    _WinAPI_DeleteObject($hBitmap)
    _WinAPI_DeleteDC($hMemDC)
EndFunc   ;==>SetBitmap


; I don't like AutoIt's built in ShellExec. I'd rather do the DLL call myself.
Func _ShellExecute($sCmd, $sArg = "", $sFolder = "", $rState = @SW_SHOWNORMAL)
    $aRet = DllCall("shell32.dll", "long", "ShellExecute", _
            "hwnd", 0, _
            "string", "", _
            "string", $sCmd, _
            "string", $sArg, _
            "string", $sFolder, _
            "int", $rState)
    If @error Then Return 0

    $RetVal = $aRet[0]
    If $RetVal > 32 Then
        Return 1
    Else
        Return 0
    EndIf
EndFunc   ;==>_ShellExecute

post-51655-1250440058199_thumb.png

post-51655-12504400666213_thumb.gif

UserName_Password.txt

Edited by MrParo
Link to comment
Share on other sites

Your logic is flawed >_<

Create the GUI using this is an easier way :(

http://www.autoitscript.com/forum/index.php?showtopic=47651&view=findpost&p=533637

The you can create your controls required for the login part (don't create another GUI). What you're doing doesn't even make sense, because you've just mashed two scripts together...

Please download the full SciTE4AutoIt3 (link in my sig), as you will find it easier.

Try to study each script to work out how it works, look at what is done, and then try to recreate those same steps.

When you've attempted it and if you still can't get it working, post your code again, and we'll have a look.

Also the file you posted doesn't look like an INI file...

Cheers,

Brett

Link to comment
Share on other sites

That thing you called a script doesn't even run for me... Many errors. >_<

Like I said before, follow what I suggested.... At least give it a go and show you tried.

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