ฟอรั่ม PSsix

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ฟอรั่มของบล็อก http://pssix.blogspot.com


2 posters

    จะสร้าง GUI Login ได้อย่างไรครับ

    avatar
    Ghost46764
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    จะสร้าง GUI Login ได้อย่างไรครับ Empty
    จำนวนข้อความ : 17
    ความนิยม : 0
    เข้าร่วมเมื่อ : 17/04/2015

    จะสร้าง GUI Login ได้อย่างไรครับ Empty จะสร้าง GUI Login ได้อย่างไรครับ

    ตั้งหัวข้อ by Ghost46764 13/06/15, 08:56 pm

    ผมอยากจะสร้างหน้าต่าง ล็อกอินอะครับ
    ตอนนี้สร้างได้ประมาณนี้แล้วครับ

    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Login", 270, 116, -1, -1)
    $UsernameEdit = GUICtrlCreateInput("", 8, 32, 233, 21, $GUI_SS_DEFAULT_INPUT)
    $ButtonOk = GUICtrlCreateButton("&OK", 86, 88, 75, 25, $BS_NOTIFY)
    $ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 88, 75, 25, $BS_NOTIFY)
    $PasswordEdit = GUICtrlCreateInput("", 8, 64, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_PASSWORD))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit

          Case $UsernameEdit
          Case $PasswordEdit
       EndSwitch
    WEnd

    ที่อยากได้ก็คือ สมมุติว่าผมจะให้ ชื่อกับรหัสที่เข้าไปได้คือ : ชื่อ Admin รหัส 46764
    คำถามก็คือ ผมจะต้องระบุตรงไหนครับ แล้วถ้าเกิดใส่ผิดให้ปิดหน้าต่างเลย ต้องทำยังไงครับ

    ท่านใดรู้ก็ช่วยๆบอกกันด้วยนะครับ ผมหาใน Google ก็ไม่เจอ  em229

    ขอบคุณล่วงหน้าครับ
    avatar
    thunmor
    PSsix Member
    PSsix Member


    จะสร้าง GUI Login ได้อย่างไรครับ Empty จะสร้าง GUI Login ได้อย่างไรครับ Empty
    จำนวนข้อความ : 26
    ความนิยม : 22
    เข้าร่วมเมื่อ : 06/08/2012

    จะสร้าง GUI Login ได้อย่างไรครับ Empty Re: จะสร้าง GUI Login ได้อย่างไรครับ

    ตั้งหัวข้อ by thunmor 20/07/15, 06:54 pm

    เขียนประมาณนี้ครับ

    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Login", 270, 116, -1, -1)
    $UsernameEdit = GUICtrlCreateInput("", 8, 32, 233, 21, $GUI_SS_DEFAULT_INPUT)
    $ButtonOk = GUICtrlCreateButton("&OK", 86, 88, 75, 25, $BS_NOTIFY)
    $ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 88, 75, 25, $BS_NOTIFY)
    $PasswordEdit = GUICtrlCreateInput("", 8, 64, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $ButtonCancel
             Exit
          Case $ButtonOk
             check()

       EndSwitch
    WEnd

    Func check()
       If GUICtrlRead($UsernameEdit) = "Admin" And GUICtrlRead($PasswordEdit) = "46764" Then
          While 1
             ToolTip("Username/Password ถูกต้องโปรแกรมกำลังทำงาน")
             Sleep(50)

             $nMsg = GUIGetMsg()
             Switch $nMsg
                Case $GUI_EVENT_CLOSE
                   Exit
                Case $ButtonCancel
                   Exit

             EndSwitch

          WEnd
       Else
          MsgBox(0, "ผิดพลาด", "UsernameหรือPassword ผิด")
          Exit
       EndIf
    EndFunc
    avatar
    Ghost46764
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    จะสร้าง GUI Login ได้อย่างไรครับ Empty
    จำนวนข้อความ : 17
    ความนิยม : 0
    เข้าร่วมเมื่อ : 17/04/2015

    จะสร้าง GUI Login ได้อย่างไรครับ Empty Re: จะสร้าง GUI Login ได้อย่างไรครับ

    ตั้งหัวข้อ by Ghost46764 21/07/15, 02:01 pm

    thunmor พิมพ์ว่า:เขียนประมาณนี้ครับ

    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Login", 270, 116, -1, -1)
    $UsernameEdit = GUICtrlCreateInput("", 8, 32, 233, 21, $GUI_SS_DEFAULT_INPUT)
    $ButtonOk = GUICtrlCreateButton("&OK", 86, 88, 75, 25, $BS_NOTIFY)
    $ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 88, 75, 25, $BS_NOTIFY)
    $PasswordEdit = GUICtrlCreateInput("", 8, 64, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $ButtonCancel
             Exit
          Case $ButtonOk
             check()

       EndSwitch
    WEnd

    Func check()
       If GUICtrlRead($UsernameEdit) = "Admin" And GUICtrlRead($PasswordEdit) = "46764" Then
          While 1
             ToolTip("Username/Password ถูกต้องโปรแกรมกำลังทำงาน")
             Sleep(50)

             $nMsg = GUIGetMsg()
             Switch $nMsg
                Case $GUI_EVENT_CLOSE
                   Exit
                Case $ButtonCancel
                   Exit

             EndSwitch

          WEnd
       Else
          MsgBox(0, "ผิดพลาด", "UsernameหรือPassword ผิด")
          Exit
       EndIf
    EndFunc

    ขอบคุณครับ
    แล้วถ้าเกิดอยากให้ล็อกอินได้หลายๆชื่อ ต้องเพิ่มตรงไหนหรอครับ
    avatar
    thunmor
    PSsix Member
    PSsix Member


    จะสร้าง GUI Login ได้อย่างไรครับ Empty จะสร้าง GUI Login ได้อย่างไรครับ Empty
    จำนวนข้อความ : 26
    ความนิยม : 22
    เข้าร่วมเมื่อ : 06/08/2012

    จะสร้าง GUI Login ได้อย่างไรครับ Empty Re: จะสร้าง GUI Login ได้อย่างไรครับ

    ตั้งหัวข้อ by thunmor 21/07/15, 03:10 pm

    ทำได้หลายวิธี จะใช้วิธีแบบตัวอย่างนี้ก็ได้
    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Login", 270, 116, -1, -1)
    $UsernameEdit = GUICtrlCreateInput("", 8, 32, 233, 21, $GUI_SS_DEFAULT_INPUT)
    $ButtonOk = GUICtrlCreateButton("&OK", 86, 88, 75, 25, $BS_NOTIFY)
    $ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 88, 75, 25, $BS_NOTIFY)
    $PasswordEdit = GUICtrlCreateInput("", 8, 64, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
      $nMsg = GUIGetMsg()
      Switch $nMsg
          Case $GUI_EVENT_CLOSE
            Exit
          Case $ButtonCancel
            Exit
          Case $ButtonOk
            check()

      EndSwitch
    WEnd

    Func check()
      If GUICtrlRead($UsernameEdit) = "Admin" And GUICtrlRead($PasswordEdit) = "46764" Then
          program()
      ElseIf GUICtrlRead($UsernameEdit) = "abc" And GUICtrlRead($PasswordEdit) = "123" Then
          program()
      ElseIf GUICtrlRead($UsernameEdit) = "def" And GUICtrlRead($PasswordEdit) = "456" Then
          program()
      Else
          MsgBox(0, "ผิดพลาด", "UsernameหรือPassword ผิด",1)
          Exit
      EndIf
    EndFunc

    Func program()
      While 1
          ToolTip("loginโดย " & GUICtrlRead($UsernameEdit))
          Sleep(50)

          $nMsg = GUIGetMsg()
          Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $ButtonCancel
                Exit

          EndSwitch

      WEnd
    EndFunc
    avatar
    Ghost46764
    สมาชิกทั่วไป
    สมาชิกทั่วไป


    จะสร้าง GUI Login ได้อย่างไรครับ Empty
    จำนวนข้อความ : 17
    ความนิยม : 0
    เข้าร่วมเมื่อ : 17/04/2015

    จะสร้าง GUI Login ได้อย่างไรครับ Empty Re: จะสร้าง GUI Login ได้อย่างไรครับ

    ตั้งหัวข้อ by Ghost46764 23/07/15, 05:55 pm

    thunmor พิมพ์ว่า:ทำได้หลายวิธี จะใช้วิธีแบบตัวอย่างนี้ก็ได้
    Code:
    #include <ButtonConstants.au3>
    #include <EditConstants.au3>
    #include <GUIConstantsEx.au3>
    #include <WindowsConstants.au3>
    #Region ### START Koda GUI section ### Form=
    $Form1 = GUICreate("Login", 270, 116, -1, -1)
    $UsernameEdit = GUICtrlCreateInput("", 8, 32, 233, 21, $GUI_SS_DEFAULT_INPUT)
    $ButtonOk = GUICtrlCreateButton("&OK", 86, 88, 75, 25, $BS_NOTIFY)
    $ButtonCancel = GUICtrlCreateButton("&Cancel", 167, 88, 75, 25, $BS_NOTIFY)
    $PasswordEdit = GUICtrlCreateInput("", 8, 64, 233, 21, BitOR($GUI_SS_DEFAULT_INPUT, $ES_PASSWORD))
    GUISetState(@SW_SHOW)
    #EndRegion ### END Koda GUI section ###

    While 1
       $nMsg = GUIGetMsg()
       Switch $nMsg
          Case $GUI_EVENT_CLOSE
             Exit
          Case $ButtonCancel
             Exit
          Case $ButtonOk
             check()

       EndSwitch
    WEnd

    Func check()
       If GUICtrlRead($UsernameEdit) = "Admin" And GUICtrlRead($PasswordEdit) = "46764" Then
          program()
       ElseIf GUICtrlRead($UsernameEdit) = "abc" And GUICtrlRead($PasswordEdit) = "123" Then
          program()
       ElseIf GUICtrlRead($UsernameEdit) = "def" And GUICtrlRead($PasswordEdit) = "456" Then
          program()
       Else
          MsgBox(0, "ผิดพลาด", "UsernameหรือPassword ผิด",1)
          Exit
       EndIf
    EndFunc

    Func program()
       While 1
          ToolTip("loginโดย " & GUICtrlRead($UsernameEdit))
          Sleep(50)

          $nMsg = GUIGetMsg()
          Switch $nMsg
             Case $GUI_EVENT_CLOSE
                Exit
             Case $ButtonCancel
                Exit

          EndSwitch

       WEnd
    EndFunc
    ขอบคุณครับบบ em238 em238

      เวลาขณะนี้ 27/04/24, 06:38 am