sunlord Posted November 29, 2006 Share Posted November 29, 2006 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! expandcollapse popupOpt("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 More sharing options...
nitekram Posted November 29, 2006 Share Posted November 29, 2006 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! expandcollapse popupOpt("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 2¢ 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." 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 More sharing options...
sunlord Posted November 29, 2006 Author Share Posted November 29, 2006 Huh? I don't get that? Link to comment Share on other sites More sharing options...
Guest JRowe_1 Posted November 29, 2006 Share Posted November 29, 2006 instead of $passwordBox , use GUICtrlRead($passwordBox) Link to comment Share on other sites More sharing options...
sunlord Posted November 29, 2006 Author Share Posted November 29, 2006 Ah! Thanks. That worked. Link to comment Share on other sites More sharing options...
sunlord Posted November 29, 2006 Author Share Posted November 29, 2006 And is there a way to automatically focus on the input box when the script is run? Link to comment Share on other sites More sharing options...
Helge Posted November 29, 2006 Share Posted November 29, 2006 #1You'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 foryour 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 rightnow, 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 More sharing options...
Mosquitos Posted November 29, 2006 Share Posted November 29, 2006 Check this topic from valuater...PC Lockout Sapiente vince, rex, noli vincere ferro! Link to comment Share on other sites More sharing options...
keen Posted December 24, 2006 Share Posted December 24, 2006 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 More sharing options...
Valuater Posted December 24, 2006 Share Posted December 24, 2006 Try This: Opt("GUIOnEventMode", 1) .......... GuiSetState() While 1 $msg = GuiGetMsg() .......... WEnd -keen you need to look at the post above from Helge #1 You're using GUIOnEventMode, so why do you have a GUIGetMsg in your loop ? 8) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now