Jump to content

Custom login box


sunlord
 Share

Recommended Posts

I'm trying to create a custom login box which will open a folder if the right password is entered. Anyone know what I'm doing wrong here? It goes to the folder no matter what password is entered!

Opt("GUIOnEventMode", 1)

#include <GuiConstants.au3>
#include <shellexecute.au3>

GuiCreate("MyGUI", 392, 318,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$okbutton = GuiCtrlCreateButton("OK", 60, 230, 90, 30)
$exitbutton = GuiCtrlCreateButton("Exit", 240, 230, 90, 30)
$passwordbox = GuiCtrlCreateInput("", 150, 190, 90, 20)
$logo = GuiCtrlCreatePic("C:\sunp.jpg", 10, 20, 380, 140)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUICtrlSetOnEvent($exitbutton, "ExitButton")
$Password = "test"

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd

Func OKButton()
 
  If $passwordbox == $Password Then
      ShellExecute(0,"open","C:\","","",@SW_SHOWNORMAL )
      Exit
      Else
      MsgBox(0, "Access Denied", "Sorry, you did not enter the correct password." & @CRLF & "Loser.")
  EndIf
  EndFunc

Func ExitButton()
    Exit
EndFunc
Link to comment
Share on other sites

I'm trying to create a custom login box which will open a folder if the right password is entered. Anyone know what I'm doing wrong here? It goes to the folder no matter what password is entered!

Opt("GUIOnEventMode", 1)

#include <GuiConstants.au3>
#include <shellexecute.au3>

GuiCreate("MyGUI", 392, 318,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$okbutton = GuiCtrlCreateButton("OK", 60, 230, 90, 30)
$exitbutton = GuiCtrlCreateButton("Exit", 240, 230, 90, 30)
$passwordbox = GuiCtrlCreateInput("", 150, 190, 90, 20)
$logo = GuiCtrlCreatePic("C:\sunp.jpg", 10, 20, 380, 140)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUICtrlSetOnEvent($exitbutton, "ExitButton")
$Password = "test"

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case Else
        ;;;
    EndSelect
WEnd

Func OKButton()
 
  If $passwordbox == $Password Then
      ShellExecute(0,"open","C:\","","",@SW_SHOWNORMAL )
      Exit
      Else
      MsgBox(0, "Access Denied", "Sorry, you did not enter the correct password." & @CRLF & "Loser.")
  EndIf
  EndFunc

Func ExitButton()
    Exit
EndFunc

You need to read the value of the ctrl before you can test it - no pun

All by me:

"Sometimes you have to go back to where you started, to get to where you want to go." 

"Everybody catches up with everyone, eventually" 

"As you teach others, you are really teaching yourself."

From my dad

"Do not worry about yesterday, as the only thing that you can control is tomorrow."

 

WindowsError.gif

WIKI | Tabs; | Arrays; | Strings | Wiki Arrays | How to ask a Question | Forum Search | FAQ | Tutorials | Original FAQ | ONLINE HELP | UDF's Wiki | AutoIt PDF

AutoIt Snippets | Multple Guis | Interrupting a running function | Another Send

StringRegExp | StringRegExp Help | RegEXTester | REG TUTOR | Reg TUTOT 2

AutoItSetOption | Macros | AutoIt Snippets | Wrapper | Autoit  Docs

SCITE | SciteJump | BB | MyTopics | Programming | UDFs | AutoIt 123 | UDFs Form | UDF

Learning to script | Tutorials | Documentation | IE.AU3 | Games? | FreeSoftware | Path_Online | Core Language

Programming Tips

Excel Changes

ControlHover.UDF

GDI_Plus

Draw_On_Screen

GDI Basics

GDI_More_Basics

GDI Rotate

GDI Graph

GDI  CheckExistingItems

GDI Trajectory

Replace $ghGDIPDll with $__g_hGDIPDll

DLL 101?

Array via Object

GDI Swimlane

GDI Plus French 101 Site

GDI Examples UEZ

GDI Basic Clock

GDI Detection

Ternary operator

Link to comment
Share on other sites

#1

You're using GUIOnEventMode, so why do you have a GUIGetMsg in your loop ?

As mentioned in the helpfile, GUIGetMsg then always returns 0, which makes it worth nothing for

your script. It could be useful if the auto-idle feature of GUIGetMsg would still work in event-mode,

but that's not the case. This also means that your script basically uses all of the CPU as it is right

now, so to avoid this I would suggest you to replace the entire msg-part with a tiny Sleep().

#2

$okbutton = GuiCtrlCreateButton("OK", 60, 230, 90, 30)
GUICtrlSetOnEvent($okbutton, "OKButton")oÝ÷ Ù8b²+¢ºÞrÖî·ZµÚ2¢ëay"±Ú'z«xò¢ì­ëh~e£¨º¹h'®­êZ²Ì(­×!yÉzZ0¶§¶´ßª$nëm¢{Ú®&鮲×(Ö¢Ø^µìm¡ûay»­¶ÚÛ(èhÁ©Þ½éíËk­çpéÚnëm¢|"¶azƦz×±¶+)ºÈ^u8Z·lmç±âʬyì!jÝý²g§¶*'yÛ§uêêºQzÛ«V¥¹ê®¢Ø§¶¡zZ_W²¢ì"[zØZµ§(Úèâ²)ìµæ­ën®wo+ayû§rبbr¬¶ÞºÇ~ð¢¹""¶ayÊ'¶º%~ÞÅ©©æò­æx"µÈZ§+wöÇ(ÞµËßöÿ¸Z+±ëmx"·l~.²;¬¶ë¶ºw-ÆP­®Tµ+Zµæ§wMúB8%jË-j׺Ú"µÍÕRPÝÙ]Ý]J  ÌÍÜÜÝÛÜÞ    ÌÍÑÕRWÑÐÕTÊ
Link to comment
Share on other sites

  • 4 weeks later...

Try This:

Opt("GUIOnEventMode", 1)

#include <GuiConstants.au3>
#include <shellexecute.au3>

GuiCreate("MyGUI", 392, 318,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS))

$okbutton = GuiCtrlCreateButton("OK", 60, 230, 90, 30)
$exitbutton = GuiCtrlCreateButton("Exit", 240, 230, 90, 30)
$passwordbox = GuiCtrlCreateInput("", 150, 190, 90, 20)
$logo = GuiCtrlCreatePic("C:\sunp.jpg", 10, 20, 380, 140)
GUICtrlSetOnEvent($okbutton, "OKButton")
GUICtrlSetOnEvent($exitbutton, "ExitButton")
$Password = "test"

GuiSetState()
While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE
        ExitLoop
    Case $okbutton
        $read = Guictrlread ( $passwordbox )
         If $read = "YOUR PASSWORD" Then
        ;Add Stuff Here(Like file stuff)

        ;End Add Stuff Here

    Case Else
       ;;;
    EndSelect
WEnd

-keen

[center]Kesne's Bar & Grill[/center]

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