Hi,
wollte noch kurz meine Func posten die ich noch fertig kriegen wollte
Ist fürn Login am Anfang des Skriptes da.
Ich denke die Beschreibung der Funktion und das Beispiel sagt alles
In Eile geschrieben also nehmt Rücksicht auf Fehler aber meldet sie
Werdet die Func auch bald in meiner Libary finden.
Spoiler anzeigen
#include <guiconstants.au3>
#include <array.au3>
Global $names = _ArrayCreate("Herbert","Gustav","Inge","Josef")
Global $pws = _ArrayCreate("a","b","c","d")
$test = _Login("Login - Test",$names,$pws)
Switch @error
Case 0
msgbox(0,"","Willkommen " & $test & ", wie gehts dir?")
Case 1
msgbox(0,"","dann nicht!")
Exit
Case 2
msgbox(0,"","Sorry! Falsches Passwort oder falscher Nutzername!")
Exit
Case 3
msgbox(0,"","inkorrektes array!")
Exit
EndSwitch
msgbox(0,"Hauptprogramm","Das hier ist das Hauptprogramm :D")
[/autoit] [autoit][/autoit] [autoit];===============================================================================
;
; Description: Login for the beginnging of a program to check users authority
; Syntax: _Login($sTitle,$sUsername,$sPassword,$BgColor = 0x000000,$TxtColor = 0xFFFFFF,$BtnColor = 0x000000)
; Parameter(s): $sTitle = Title of the box
; $sUsername = one username for login, or for more users an 1 dimensional array with usernames,
; first username belongs to first $sPassword, second username belongs to second $sPassword,
; third username belongs to third $sPassword, ... no limit set
; $sPassword = one password for login, or for more users an 1 dimensional array with passwords,
; first password belongs to first $sUsername, second password belongs to second $sUsername, ...
; $BgColor = Background color of the GUI, default = black
; $TxtColor = Text color of the GUI, default = white
; $BtnColor = Button color of the GUI, default = black
; Requirement(s): #include <guiconstants.au3>
; Return Value(s): On Success - Returns $sUsername wich the user logged in
; On Failure - Returns 0 and sets @error
; 1 = User exited the Login Window
; 2 = Username or password wrong
; 3 = incorrect array given
; Author(s): qon
; Note(s): You don't have to create an array for usernames/passwords if you only need one username / passsword.
;
;===============================================================================
Func _Login($sTitle,$sUsername,$sPassword,$BgColor = 0x000000,$TxtColor = 0xFFFFFF,$BtnColor = 0x000000)
$LoginGui = GuiCreate("Login",250,100)
$NameLabel = GuiCtrlCreateLabel("username",12,11)
$Name = GuiCtrlCreateInput("",70,10,165)
$PwLabel = GuiCtrlCreateLabel("password",12,40)
$Pw = GuiCtrlCreateInput("",70,38,165,-1,$ES_PASSWORD)
$Login = GuiCtrlCreateButton("Login",75,67,100)
GuiSetBkColor($BgColor,$LoginGui)
GuiCtrlSetColor($NameLabel,$TxtColor)
GuiCtrlSetColor($PwLabel,$TxtColor)
GuiCtrlSetBkColor($Login,$BtnColor)
GuiCtrlSetColor($Login,$TxtColor)
GuiSetState()
While 1
Switch GuiGetMsg()
Case $GUI_EVENT_CLOSE
GuiDelete($LoginGui)
SetError(1)
Return 0
Case $Login
If Not IsArray($sUsername) and Not IsArray($sPassword) Then
If GuiCtrlRead($Name) = $sUsername and GuiCtrlRead($Pw) = $sPassword Then
GuiDelete($LoginGui)
Return $sUsername
Else
GuiDelete($LoginGui)
SetError(2)
Return 0
EndIf
ElseIf IsArray($sUsername) and IsArray($sPassword) Then
If (UBound($sUsername,0) <> 1) or (UBound($sPassword,0) <> 1) or (UBound($sUserName,1) <> UBound($sPassword,1)) Then
GuiDelete($LoginGui)
SetError(3)
Return 0
EndIf
$UN = GuiCtrlRead($Name)
$UP = GuiCtrlRead($Pw)
For $i = 0 to UBound($sUsername)-1
If $UN = $sUsername[$i] and $UP = $sPassword[$i] Then
GuiDelete($LoginGui)
Return $sUserName[$i]
EndIf
Next
GuiDelete($LoginGui)
SetError(2)
Return 0
Else
GuiDelete($LoginGui)
SetError(3)
Return 0
EndIf
EndSwitch
WEnd
EndFunc
edit: ich hab irgendwo nen blöden fehler, werd mich morgen drum kümmern.
edit2: War ein falscher Funktionsaufruf von mir - wie peinlich
Und noch etwas: der Gui wurde nicht deleted, wenn die Angaben stimmten, auch gefixt.
Greetz