Sign in to follow this  
Followers 0
Kyme

Log in help

3 posts in this topic

i have this script:

what i need to add when i didn't write something in id or pass to give me

MsgBox(64, "Info", "please write youre id and pass")

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <inet.au3>


$Menu1 = GUICreate("Login", 269, 164, 283, 207)

$guiuser=GUICtrlCreateInput("", 120, 40, 113, 21)
$guipassw=GUICtrlCreateInput("", 120, 72, 113, 21)


$Label1 = GUICtrlCreateLabel("ID:", 40, 43, 36, 20)
$Label2 = GUICtrlCreateLabel("Password:", 40, 75, 67, 20)

$ok = GUICtrlCreateButton("&OK", 38, 115, 75, 25, 0)
$cancel = GUICtrlCreateButton("&Cancel", 157, 116, 75, 25, 0)
GUISetState(@SW_SHOW)

$checkid = _InetIniRead("http://kyme32.webs.com/data2.txt","Kyme32","ID",GUICtrlRead($guiuser))
$checkpass= _InetIniRead("http://kyme32.webs.com/data2.txt","Kyme32","Pass",GUICtrlRead($guipassw))

;~ ID=Kyme32
;~ Pass=thepass

While 1
       Switch GUIGetMsg()
        
    Case $ok
            If GuiCtrlRead($guiuser) = $checkid And GuiCtrlRead($guipassw) = $checkpass Then
                MsgBox(64, "Info", "You have log in...")
            Else
                MsgBox(16, "Error", "Incorect user or password")
            EndIf
        
        Case $cancel, $GUI_EVENT_CLOSE
            Exit
        
    EndSwitch
WEnd

Func _InetIniRead($s_url, $v_section, $v_key, $v_default = -1)
    If $v_default = -1 Or $v_default = Default Then $v_default = ""
    Local $s_text = _INetGetSource($s_url)
    If $s_text = "" Then Return SetError(1, 0, "")
    $s_text = @CRLF & $s_text & @CRLF
    $v_section = StringStripWS($v_section, 7)
    Local $a_data = StringRegExp($s_text, "(?s)(?i)\n\s*\[\s*" & $v_section & "\s*\]\s*\r\n(.*?)(?m:\[|\z)", 3)
    If IsArray($a_data) = 0 Then Return SetError(2, 0, "")
    Local $a_read = StringRegExp(@LF & $a_data[0], "(?s)(?i)\n\s*" & $v_key & "\s*=(.*?)\r", 1)
    If IsArray($a_read) = 0 Then Return SetError(3, 0, "")
    Return $a_read[0]
EndFunc

tnx

Share this post


Link to post
Share on other sites



You may want to replace your "if" statement to this

If GuiCtrlRead($guiuser) = $checkid And GuiCtrlRead($guipassw) = $checkpass Then
     MsgBox(64, "Info", "You have log in...")
ElseIf GuiCtrlRead($guiuser) = "" Then
     MsgBox(16, "Error", "You must enter a your user name")
ElseIf GuiCtrlRead($guipassw) = "" Then
     MsgBox(16, "Error", "You must enter a your password")
Else
      MsgBox(16, "Error", "Incorect user or password")
EndIf

Share this post


Link to post
Share on other sites

i have this script:

what i need to add when i didn't write something in id or pass to give me

MsgBox(64, "Info", "please write youre id and pass")

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIConstants.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <inet.au3>


$Menu1 = GUICreate("Login", 269, 164, 283, 207)

$guiuser=GUICtrlCreateInput("", 120, 40, 113, 21)
$guipassw=GUICtrlCreateInput("", 120, 72, 113, 21)


$Label1 = GUICtrlCreateLabel("ID:", 40, 43, 36, 20)
$Label2 = GUICtrlCreateLabel("Password:", 40, 75, 67, 20)

$ok = GUICtrlCreateButton("&OK", 38, 115, 75, 25, 0)
$cancel = GUICtrlCreateButton("&Cancel", 157, 116, 75, 25, 0)
GUISetState(@SW_SHOW)

$checkid = _InetIniRead("http://kyme32.webs.com/data2.txt","Kyme32","ID",GUICtrlRead($guiuser))
$checkpass= _InetIniRead("http://kyme32.webs.com/data2.txt","Kyme32","Pass",GUICtrlRead($guipassw))

;~ ID=Kyme32
;~ Pass=thepass

While 1
       Switch GUIGetMsg()
        
    Case $ok
            If GuiCtrlRead($guiuser) = $checkid And GuiCtrlRead($guipassw) = $checkpass Then
                MsgBox(64, "Info", "You have log in...")
            Else
                MsgBox(16, "Error", "Incorect user or password")
            EndIf
        
        Case $cancel, $GUI_EVENT_CLOSE
            Exit
        
    EndSwitch
WEnd

Func _InetIniRead($s_url, $v_section, $v_key, $v_default = -1)
    If $v_default = -1 Or $v_default = Default Then $v_default = ""
    Local $s_text = _INetGetSource($s_url)
    If $s_text = "" Then Return SetError(1, 0, "")
    $s_text = @CRLF & $s_text & @CRLF
    $v_section = StringStripWS($v_section, 7)
    Local $a_data = StringRegExp($s_text, "(?s)(?i)\n\s*\[\s*" & $v_section & "\s*\]\s*\r\n(.*?)(?m:\[|\z)", 3)
    If IsArray($a_data) = 0 Then Return SetError(2, 0, "")
    Local $a_read = StringRegExp(@LF & $a_data[0], "(?s)(?i)\n\s*" & $v_key & "\s*=(.*?)\r", 1)
    If IsArray($a_read) = 0 Then Return SetError(3, 0, "")
    Return $a_read[0]
EndFunc

tnx

Would this do what you want?

Case $ok
            If GUICtrlRead($guiuser) = "" Or GUICtrlRead($guipassw) = "" Then
                MsgBox(64, "Info", "Please enter your user name and ID.")
            ElseIf GUICtrlRead($guiuser) = $checkid And GUICtrlRead($guipassw) = $checkpass Then
                MsgBox(64, "Info", "You have log in...")
            Else
                MsgBox(16, "Error", "Incorect user or password")
            EndIf

Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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
Sign in to follow this  
Followers 0