gcue Posted January 15, 2010 Share Posted January 15, 2010 (edited) within a for loop, i prompt for a credential login. (which is a guicreate) if the user leaves the prompt on without logging in, the for loop continues to the next item expandcollapse popup#include <WindowsConstants.au3> #Include <GuiEdit.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $pc, $array[3], $credentials_child, $netsupport_login_successful = False $array[0] = "1" $array[1] = "2" $array[1] = "3" For $x = 1 to UBound($array) - 1 $pc = $array[$x] If $netsupport_login_successful = False Then Netsupport_Prompt() Else Netsupport_Login() EndIf Next Func Netsupport_Prompt() If WinExists("Netsupport Buddy Login") Then MsgBox(262144, "Dashboard", "Already running Netsupport Buddy Login.") Return EndIf $credentials_child = GUICreate("Netsupport Buddy Login", 265, 90, -1, -1, $WS_EX_MDICHILD, $WS_EX_TOPMOST) $username_input = GUICtrlCreateInput(@UserName, 5, 5, 200, 20) $password_input = GUICtrlCreateInput("", 5, 30, 200, 20, $ES_PASSWORD) GUICtrlSetState(-1, $gui_focus) $OK_btn = GUICtrlCreateButton("OK", 210, 5, 40, 20) GUICtrlSetOnEvent(-1, "Netsupport_Login") $CANCEL_btn = GUICtrlCreateButton("Cancel", 210, 30, 40, 20) GUICtrlSetOnEvent(-1, "DEL_credentials_child") GUISetState() EndFunc ;==>Netsupport_Prompt func DEL_credentials_child() exit EndFunc Func Netsupport_Login() $netsupport_login_successful = True MsgBox(0,"",$pc) EndFunc ;==>Netsupport_Login while 1 sleep(10) WEnd Edited January 15, 2010 by gcue Link to comment Share on other sites More sharing options...
Xenobiologist Posted January 15, 2010 Share Posted January 15, 2010 And the question is? Scripts & functions Organize Includes Let Scite organize the include files Yahtzee The game "Yahtzee" (Kniffel, DiceLion) LoginWrapper Secure scripts by adding a query (authentication) _RunOnlyOnThis UDF Make sure that a script can only be executed on ... (Windows / HD / ...) Internet-Café Server/Client Application Open CD, Start Browser, Lock remote client, etc. MultipleFuncsWithOneHotkey Start different funcs by hitting one hotkey different times Link to comment Share on other sites More sharing options...
jchd Posted January 15, 2010 Share Posted January 15, 2010 The "code" posted doesn't make sense. It won't even pass AutoIt check, and it does serve no purpose. What is the point of setting up a GUI if you don't get anything from it? The For loop has syntax error. Your test is hanging in the sky. Other function is missing. So what? This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
gcue Posted January 15, 2010 Author Share Posted January 15, 2010 (edited) sorry sometimes i try not to post too long of a code otherwise folks might not bother to read. i have revised my script in my post ABOVE to better illustrate my point - again sorry about that. my question is: the array goes through the first record and prompts for a password if authentication has not been provided but if the user does not enter their credentials right away, the for loop continues anyway. i want the loop to stop until the user has entered his/her credentials so when i call the function within the loop, is there a way i can make it wait until the user has entered credentials? i thought maybe in the way i call the function it could be done (but runwait seems to be only for EXEs or files) or i can use a condition if $netsupport_login_successful = true then continueloop but what if its false? do sleep until $netsupport_login_successful = True wont that tie up the script from the user entering his credentials? Edited January 15, 2010 by gcue Link to comment Share on other sites More sharing options...
jchd Posted January 16, 2010 Share Posted January 16, 2010 my question is: the array goes through the first record and prompts for a password if authentication has not been provided but if the user does not enter their credentials right away, the for loop continues anyway. i want the loop to stop until the user has entered his/her credentialsThat's logical. Since you don't bother to even read what the user has entered, I hardly see how you can validate anything.You need to GUICtrlGetData from your input controls and do something to validate what has been entered, e.g. perform loging in. If you find that, say, the password has been left blank, then you should probably avoid invoking GUICtrlSetOnEvent(-1, "Netsupport_Login")automatically! This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
gcue Posted January 16, 2010 Author Share Posted January 16, 2010 i do bother to read it.. the actual script is much longer.. but this script illustrates the process and what im trying to wait on Link to comment Share on other sites More sharing options...
jchd Posted January 16, 2010 Share Posted January 16, 2010 i do bother to read it.. the actual script is much longer.. but this script illustrates the process and what im trying to wait onYour mutilated script doesn't illustrate anything as it stands.Show where you get the user input and what you do with hat data. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
gcue Posted January 16, 2010 Author Share Posted January 16, 2010 if you run this you will see what im getting at... before the user can enter credentials into the GUI the for loop continues and another GUI tries to get created... how can i do a Wait for Input in a for loop? expandcollapse popup#include <WindowsConstants.au3> #Include <GuiEdit.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $pc, $array[3], $credentials_child, $netsupport_login_successful = False $array[0] = "1" $array[1] = "2" $array[2] = "3" For $x = 0 to UBound($array) - 1 $pc = $array[$x] If $netsupport_login_successful = False Then Netsupport_Prompt() Else Netsupport_Login() EndIf Next exit Func Netsupport_Prompt() If WinExists("Netsupport Buddy Login") Then MsgBox(262144, "Dashboard", "Already running Netsupport Buddy Login.") Return EndIf $credentials_child = GUICreate("Netsupport Buddy Login", 265, 90, -1, -1, $WS_EX_MDICHILD, $WS_EX_TOPMOST) $username_input = GUICtrlCreateInput(@UserName, 5, 5, 200, 20) $password_input = GUICtrlCreateInput("", 5, 30, 200, 20, $ES_PASSWORD) GUICtrlSetState(-1, $gui_focus) $OK_btn = GUICtrlCreateButton("OK", 210, 5, 40, 20) GUICtrlSetOnEvent(-1, "Netsupport_Login") $CANCEL_btn = GUICtrlCreateButton("Cancel", 210, 30, 40, 20) GUICtrlSetOnEvent(-1, "DEL_credentials_child") GUISetState() EndFunc ;==>Netsupport_Prompt func DEL_credentials_child() Exit EndFunc Func Netsupport_Login() $netsupport_login_successful = True ConsoleWrite($pc & @LF) GUIDelete($credentials_child) EndFunc ;==>Netsupport_Login while 1 sleep(10) WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 16, 2010 Moderators Share Posted January 16, 2010 gcue,Just use the flag you already have as the condition for a While...WEnd loop:expandcollapse popupFunc Netsupport_Prompt() If WinExists("Netsupport Buddy Login") Then MsgBox(262144, "Dashboard", "Already running Netsupport Buddy Login.") Return EndIf $credentials_child = GUICreate("Netsupport Buddy Login", 265, 90, -1, -1, $WS_EX_MDICHILD, $WS_EX_TOPMOST) $username_input = GUICtrlCreateInput(@UserName, 5, 5, 200, 20) $password_input = GUICtrlCreateInput("", 5, 30, 200, 20, $ES_PASSWORD) GUICtrlSetState(-1, $gui_focus) $OK_btn = GUICtrlCreateButton("OK", 210, 5, 40, 20) GUICtrlSetOnEvent(-1, "Netsupport_Login") $CANCEL_btn = GUICtrlCreateButton("Cancel", 210, 30, 40, 20) GUICtrlSetOnEvent(-1, "DEL_credentials_child") GUISetState() While $netsupport_login_successful = False Sleep(10) WEnd ConsoleWrite("We are here because the log-in was successful" & @CRLF) EndFunc ;==>Netsupport_Prompt Func Netsupport_Login() ; Errorcheck inputs If GUICtrlRead($username_input) = "" Or GUICtrlRead($password_input) = "" Then Return ; You only want to set this value to True IF the login was successful!!!!! $netsupport_login_successful = True ConsoleWrite($pc & @LF) GUIDelete($credentials_child) EndFunc ;==>Netsupport_LoginBut as it says in the comment line, you MUST make sure your log-in is successful before you set the flag to True.I hope this helps. M23  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 columnsChooseFileFolder ---- Single and multiple selections from specified path treeview listingDate_Time_Convert -- Easily convert date/time formats, including the language usedExtMsgBox --------- A highly customisable replacement for MsgBoxGUIExtender -------- Extend and retract multiple sections within a GUIGUIFrame ---------- Subdivide GUIs into many adjustable framesGUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView itemsGUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeViewMarquee ----------- Scrolling tickertape GUIsNoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxesNotify ------------- Small notifications on the edge of the displayScrollbars ----------Automatically sized scrollbars with a single commandStringSize ---------- Automatically size controls to fit textToast -------------- Small GUIs which pop out of the notification area  Link to comment Share on other sites More sharing options...
Rex Posted January 16, 2010 Share Posted January 16, 2010 if you run this you will see what im getting at... before the user can enter credentials into the GUI the for loop continues and another GUI tries to get created... how can i do a Wait for Input in a for loop? expandcollapse popup#include <WindowsConstants.au3> #Include <GuiEdit.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $pc, $array[3], $credentials_child, $netsupport_login_successful = False $array[0] = "1" $array[1] = "2" $array[2] = "3" For $x = 0 to UBound($array) - 1 $pc = $array[$x] If $netsupport_login_successful = False Then Netsupport_Prompt() Else Netsupport_Login() EndIf Next exit Func Netsupport_Prompt() If WinExists("Netsupport Buddy Login") Then MsgBox(262144, "Dashboard", "Already running Netsupport Buddy Login.") Return EndIf $credentials_child = GUICreate("Netsupport Buddy Login", 265, 90, -1, -1, $WS_EX_MDICHILD, $WS_EX_TOPMOST) $username_input = GUICtrlCreateInput(@UserName, 5, 5, 200, 20) $password_input = GUICtrlCreateInput("", 5, 30, 200, 20, $ES_PASSWORD) GUICtrlSetState(-1, $gui_focus) $OK_btn = GUICtrlCreateButton("OK", 210, 5, 40, 20) GUICtrlSetOnEvent(-1, "Netsupport_Login") $CANCEL_btn = GUICtrlCreateButton("Cancel", 210, 30, 40, 20) GUICtrlSetOnEvent(-1, "DEL_credentials_child") GUISetState() EndFunc ;==>Netsupport_Prompt func DEL_credentials_child() Exit EndFunc Func Netsupport_Login() $netsupport_login_successful = True ConsoleWrite($pc & @LF) GUIDelete($credentials_child) EndFunc ;==>Netsupport_Login while 1 sleep(10) WEnd U could also wait for U'r gui to be closed expandcollapse popup#include <WindowsConstants.au3> #Include <GuiEdit.au3> #include <GUIConstantsEx.au3> Opt("GUIOnEventMode", 1) Global $pc, $array[3], $credentials_child, $netsupport_login_successful = False $array[0] = "1" $array[1] = "2" $array[2] = "3" For $x = 0 to UBound($array) - 1 $pc = $array[$x] If $netsupport_login_successful = False Then Netsupport_Prompt() WinWaitClose("Netsupport Buddy Login", "") Else Netsupport_Login() EndIf Next exit Func Netsupport_Prompt() If WinExists("Netsupport Buddy Login") Then MsgBox(262144, "Dashboard", "Already running Netsupport Buddy Login.") Return EndIf $credentials_child = GUICreate("Netsupport Buddy Login", 265, 90, -1, -1, $WS_EX_MDICHILD, $WS_EX_TOPMOST) $username_input = GUICtrlCreateInput(@UserName, 5, 5, 200, 20) $password_input = GUICtrlCreateInput("", 5, 30, 200, 20, $ES_PASSWORD) GUICtrlSetState(-1, $gui_focus) $OK_btn = GUICtrlCreateButton("OK", 210, 5, 40, 20) GUICtrlSetOnEvent(-1, "Netsupport_Login") $CANCEL_btn = GUICtrlCreateButton("Cancel", 210, 30, 40, 20) GUICtrlSetOnEvent(-1, "DEL_credentials_child") GUISetState() EndFunc ;==>Netsupport_Prompt func DEL_credentials_child() Exit EndFunc Func Netsupport_Login() $netsupport_login_successful = True ConsoleWrite($pc & @LF) GUIDelete($credentials_child) EndFunc ;==>Netsupport_Login while 1 sleep(10) WEnd Cheers /Rex Link to comment Share on other sites More sharing options...
gcue Posted January 17, 2010 Author Share Posted January 17, 2010 awesome thanks fellas. 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