Jump to content

login form for access to open program


Recommended Posts

Hi,

I need a login form for access to main page of my program, i have that code but i think this is incorrect or need some line of code to fix this problem,

;
; BEGIN LOGIN AUTHENTICATION
;

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

#NoTrayIcon
Opt('WinTitleMatchMode', 2)
Opt('GUIOnEventMode', 1)
Opt('GUICloseOnESC', 0)

Global $AuthFlag = 1
Global $LoginForm = GUICreate("Login", 220, 112)
Global $UsernameLabel = GUICtrlCreateLabel("Username", 5, 10, 80, 22)
Global $UsernameInput = GUICtrlCreateInput("", 90, 8, 121, 26)
Global $PasswordLabel = GUICtrlCreateLabel("Password", 5, 45, 78, 22)
Global $PasswordInput = GUICtrlCreateInput("", 90, 43, 121, 26, $ES_PASSWORD)
Global $LoginButton = GUICtrlCreateButton("Login", 5, 78, 207, 25)

GUISetFont(12, 400, 0, "Arial")
GUISetOnEvent($GUI_EVENT_CLOSE, "LoginFormClose")
GUICtrlSetCursor(-1, 0)
GUICtrlSetOnEvent(-1, "LoginButton_Click")
GUISetIcon(@ScriptDir & "\Icons\cocbot.ico")
GUISetState(@SW_SHOW)

While $AuthFlag
    Sleep(250)
WEnd

Func LoginButton_Click()
    GUICtrlSetState($LoginButton, 128)
    GUICtrlSetData($LoginButton, "Authenticating...")

    If Login(StringStripWS(GUICtrlRead($UsernameInput), 3), StringStripWS(GUICtrlRead($PasswordInput), 3)) Then
        $AuthFlag = 0;
        GUIDelete($LoginForm)
    Else
        MsgBox(262160, "Error", "Invalid username and/or password. Please ensure that you are using your http://www.parsitek.com forum credentials.")
    EndIf

    GUICtrlSetState($LoginButton, 64)
    GUICtrlSetData($LoginButton, "Login")
    GUICtrlSetState($UsernameInput, 256)
EndFunc

Func Login($Username, $Password)
    Local $oHTTP = ObjCreate("winhttp.winhttprequest.5.1")
    Local $POSTData = "u=" & $Username & "&p=" & $Password

    $oHTTP.Open("POST", "http://parsitek.com/wpp/wp-login.php", True)
    $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded")
    $oHTTP.Send($POSTData)

    If $oHTTP.Status <> 200 Then
        MsgBox(262160, "Error", "There was an issue authenticating with ClashBot, please report this to a developer.")
        Return False
    EndIf

    Return $oHTTP.ResponseText <> "#denied#"
EndFunc

Func LoginFormClose()
    Exit
EndFunc

;
; END LOGIN AUTHNENTICATION
;

please help me to fix this problem dears ,

thanks a lot

Link to comment
Share on other sites

Hello,

Maybe a WaitForResponse() below your Send helps.

$oHTTP.Send($POSTData)
    $oHTTP.WaitForResponse()

P.S. you have posted in the wrong section and have you read the >forum rules?

 

i'm so sorry ,

i try this but not work , when i insert this code, application can open without correct username and password!

Link to comment
Share on other sites

  • Moderators

wolf1600u,

Welcome to the AutoIt forum. :)

But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "This is NOT a general support forum!". I have moved it for you, but would ask you to be more careful in future. ;)

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

gotcha...

at line 57

MsgBox(262160, "Error", "There was an issue authenticating with ClashBot, please report this to a developer."

he's creating login form for CoC Bot...

at line 25

GUISetIcon(@ScriptDir & "\Icons\cocbot.ico")
Edited by 232showtime

ill get to that... i still need to learn and understand a lot of codes graduated.gif

Correct answer, learn to walk before you take on that marathon.

Link to comment
Share on other sites

wolf1600u,

Welcome to the AutoIt forum. :)

But please pay attention to where you post - the "Examples" section where you started this thread is clearly marked: "This is NOT a general support forum!". I have moved it for you, but would ask you to be more careful in future. ;)

M23

 

thanks Melba23,

i'm so sorry about this

Link to comment
Share on other sites

  • Moderators

wolf1600u,

 

it just easy login page !

Even so, it is still gaming interaction - thread locked. :naughty:

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

Guest
This topic is now closed to further replies.
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...