badapple89 Posted March 22, 2013 Share Posted March 22, 2013 Hey guys.Got a pretty good script going. Not sure if background helps but I love what autoIT can do so Ill tell you We are automating the login to one of our programs, the script will launch a GUI that looks like the normal login screen (got a cheeky screenshot of origonal and set it in the GUI).The user puts in username and password to GUI and presses login (or enter) (there is also a cancel button).The details are then saved to an INI file.The REAL program is then called and details read back and typed into the login screen.If the real program gets a wrong password error (User typed details wrong into GUI) the login GUI is rw-showen again and the user can put in correct detailsThen next time the user runs it it will just grab the INI and auto login without showing the GUI.COOL!The problem is with step 4. The GUI relaunches but the login button, cancel button, close button WONT work. But using Enter does!!! Not sure where I wront wrong.Even put GUIDelete ("Insight Autologin Setup") in the functions that the buttons are callingHere is the main code for gui.Func LoginGUI() ;Declair Global $GUISetup, $saveUsernameBox, $savePasswordBox, $butCancel Global $saveUsername = "" ;Set GUI Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $GUISetup = GUICreate("Insight Autologin Setup", 335, 290) WinSetOnTop($GUISetup, "", 1) $butLogin = GUICtrlCreateButton("Login", 77, 227, 80) GUICtrlSetOnEvent($butLogin, "Save_Details") $butCancel = GUICtrlCreateButton("Cancel", 187, 227, 80) GUICtrlSetOnEvent($butCancel, "On_Close") GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ;Show GUI as hidden by default GUISetState(@SW_SHOW) ;Idle around only needed for main GUI While 1 Sleep(50) ;If Enter (0D) is pressed then save details IF _IsPressed("0D") Then Save_Details() EndIf WEnd EndFunc ;==>LoginGUIHere is what the login button does.Func Save_Details() ;Create INI FileOpen($LoginIni, 10) ;Read details $saveUsername = GUICtrlRead($saveUsernameBox) ;Write to INI IniWrite($LoginIni, "LoginDetails", "Username", $saveUsername) ;Read Details $savePassword = GUICtrlRead($savePasswordBox) ;Write to INI IniWrite($LoginIni, "LoginDetails", "Password", $savePassword) GUIDelete ("Insight Autologin Setup") RunInsight() EndFunc ;==>Save_DetailsHope you guys can help! Link to comment Share on other sites More sharing options...
PhoenixXL Posted March 22, 2013 Share Posted March 22, 2013 Automated Login is not allowed for open discussion, please check the Forum Rules( at the bottom right of every page )Regards My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted March 22, 2013 Moderators Share Posted March 22, 2013 PhoenixXL,Automated Login is not allowed for open discussionYes it is - have you actually read the Forum rules yourself? We do not permit discussion of "log-in and security dialogs" - but plain vanilla logins are perfectly legal. badapple89,Nevertheless I am not very happy with what you want to do - having a fake login screen that looks like the real one and capturing login details is not what I would regard as something we would want to support here. So I suggest you provide some more details of this "Insight" software and why you need to bypass the normal login by having the details stored in an insecure ini file. Why bother with a login at all? If you do not want to post details in the thread then send me a PM - but until I get some more information I will take a very dim view of anyone offering any help in this thread. 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...
PhoenixXL Posted March 22, 2013 Share Posted March 22, 2013 Oh I thought its a webform login, My code: PredictText: Predict Text of an Edit Control Like Scite. Remote Gmail: Execute your Scripts through Gmail. StringRegExp:Share and learn RegExp.Run As System: A command line wrapper around PSEXEC.exe to execute your apps scripts as System (LSA). Database: An easier approach for _SQ_LITE beginners. MathsEx: A UDF for Fractions and LCM, GCF/HCF. FloatingText: An UDF for make your text floating. Clipboard Extendor: A clipboard monitoring tool. Custom ScrollBar: Scroll Bar made with GDI+, user can use bitmaps instead. RestrictEdit_SRE: Restrict text in an Edit Control through a Regular Expression. Link to comment Share on other sites More sharing options...
badapple89 Posted April 1, 2013 Author Share Posted April 1, 2013 Hey guys, Sorry to cause issue. I thought It might not be allowed while I was writing it. So the reason: We are a small business and have about 80 users in total. They log onto there PC each day using exchange and then launch insight, they then have to log-in to that with different details. Out goal is to get rid of the 2nd step of having to log into the program, this will also mean they wont have to remember an extra username and password (always a good thing as our staff are not that computer savvy). The issue is our the program does not support auto login (and we have been told bt the devs that it wont in future releases). So I've been playing with Auto IT and wanted to make a progamm to do this (how program runs is outlined in first post). Why I tried to copy the original log-in screen? The auto-it-login screen is a screenshot of the origonal login but with details altered so the user knows what is happening (its more to give it the same feel as the origonal prograqmm). Also we will send out an email before any implementation but if we simply implemented this with a stock standard auto-it pop-up peoples minds would explode and 50 of them would call me (even if they had read the email). In relations to the INI's being insecure. Its not a big risk to us. People currently do not regard there insight log-in details as secure and are not required to. Hope this outlines my project a bit more clearly. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 2, 2013 Moderators Share Posted April 2, 2013 badapple89, I understand now what you are trying to do. Please post the whole script - only then can we determine what is preventing the buttons from working. It would also help if you could describe the normal and failure cases for an Insight login (including the titles of any GUIs and dialogs that appear) so that we can develop some code to correctly diagnose the result and branch the code accordingly. 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...
badapple89 Posted April 2, 2013 Author Share Posted April 2, 2013 Thanks so much dude Im new to AutoIT and coding in general, so sorry if its poorly laid out. Any tips on keeping code/general rules neat would be a help expandcollapse popup#region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=H:\Scripts\AutoIT\Insight Launcher\InsightLauncher.ico #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #RequireAdmin #include #include #include ;Only run one version of script. ;_Singleton ("InsightLauncher") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Checks network files ; ; Prompts for user details & stored in INI file ; ; Launches $Insight and uses INI to auto login ; ; ; ; If no INI exists then prompt to create INI will appear each time ; ; If INI exists but details are blank then Insight will run as normal ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Name files $insight = "x:\InsightCurrent.exe" $InsightLauncher = "\\adl-file\IT\Scripts\AutoIT\Insight Launcher\Insight.exe" $LoginIni = "x:\InsightINI\" & @UserName & ".ini" ;Declair Global $GUISetup, $saveUsernameBox, $savePasswordBox, $butCancel, $butLogin Global $saveUsername = "" ;Check for actual insight If not FileExists ($insight) Then MsgBox (16, "Insight", "Error network file not found " & @lf & $insight) Exit EndIF If not FileExists ($LoginIni) Then ;Call GUI LoginGUI() Else RunInsight() EndIf ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; GUI controls & Functions ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func LoginGUI() ;Set GUI Opt("GUIOnEventMode", 1) ; Change to OnEvent mode $GUISetup = GUICreate("Insight Autologin Setup", 335, 290) WinSetOnTop($GUISetup, "", 1) ;Set Background $GUIBackground = GUICtrlCreatePic("H:\Scripts\AutoIT\Insight Launcher\login.jpg", 0, 0, 335, 290) ;Disble it so can click in input boxes GUICtrlSetState(-1, $GUI_DISABLE) ;Create input boxes $saveUsernameBox = GUICtrlCreateInput("", 89, 130, 185, 21) $savePasswordBox = GUICtrlCreateInput("", 89, 155, 185, 21, BitOR("", $ES_PASSWORD)) $butLogin = GUICtrlCreateButton("Login", 77, 227, 80) GUICtrlSetOnEvent($butLogin, "Save_Details") $butCancel = GUICtrlCreateButton("Cancel", 187, 227, 80) GUICtrlSetOnEvent($butCancel, "On_Close") GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ;Show GUI as hidden by default GUISetState(@SW_SHOW) ;Idle around only needed for main GUI While 1 Sleep(50) ;If Enter (0D) is pressed then save details IF _IsPressed("0D") Then Save_Details() EndIf WEnd EndFunc ;==>LoginGUI Func Save_Details() GUIDelete ("Insight Autologin Setup") ;Create INI FileOpen($LoginIni, 10) ;Read details $saveUsername = GUICtrlRead($saveUsernameBox) ;Write to INI IniWrite($LoginIni, "LoginDetails", "Username", $saveUsername) ;Read Details $savePassword = GUICtrlRead($savePasswordBox) ;Write to INI IniWrite($LoginIni, "LoginDetails", "Password", $savePassword) GUIDelete ("Insight Autologin Setup") RunInsight() EndFunc ;==>Save_Details Func RunInsight() ;Open insight Run($insight) ;Wait till insight login screen WinWaitActive("Insight Log in") ;Keep window open wile sending keys SendKeepActive("Insight Log in") ;Get username and password from LoginIni $Username = IniRead($LoginIni, "LoginDetails", "Username", "") $Password = IniRead($LoginIni, "LoginDetails", "Password", "") ;If Username is not blank If not $Username = "" Then ;Send text (insight will default to password section so tab 4 times first) Send("{TAB 4}" & $Username & "{TAB}" & $Password & "{ENTER}") EndIf ;If error received on login (most likley due to incorrect password) If WinWaitActive ("Error", "", 15) Then ;Wait for message to close WinWaitClose ("Error") ;Close login window Send ("!c") ;Re-run login setup LoginGUI() EndIf Exit EndFunc Func On_Close() Switch @GUI_CTRLID ; See which GUI sent the CLOSE message Case $GUI_EVENT_CLOSE ; If it was this GUI - we exit GUIDelete ("Insight Autologin Setup") Exit Case $butCancel ;If it was $butCancel do the following GUIDelete ("Insight Autologin Setup") ;Below will set blank INI if cancell pressed. ;~ IniWrite($LoginIni, "LoginDetails", "Username", "") ;~ IniWrite($LoginIni, "LoginDetails", "Password", "") ;~ RunInsight() Exit EndSwitch EndFunc ;==>On_Close The login screen and error screen are mentioned in the code. WinWaitActive("Insight Log in") WinWaitActive ("Error", "", 15) The reason for the wait 15 is that if you enter a wrong username and password the error msg can take up to 15 seconds to come up (Just when running insight normally, although it gernally comes up within 5) Upon stressful log-in the main window is "Insight 8.0 licensed to ***** ****" and class of "TfrmDesktop" Haven't referenced that as it wont ALWAYS be version 8.0 I'm sure its something easy, but happy to provide any other info. Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted April 3, 2013 Moderators Share Posted April 3, 2013 badapple89, I think this should do what you want - I have tested it as far as I am able without having access to the actual app! The comments should make it clear what is going on and why I have done what I have done: expandcollapse popup#Region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_Icon=H:\Scripts\AutoIT\Insight Launcher\InsightLauncher.ico #AutoIt3Wrapper_Res_requestedExecutionLevel=asInvoker #Endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #RequireAdmin #include <GUIConstantsEx.au3> #include <EditConstants.au3> #include <ButtonConstants.au3> Opt("GUIOnEventMode", 1) ; Change to OnEvent mode ; Put this at the top <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Only run one version of script. ;_Singleton ("InsightLauncher") ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ; ; ; Checks network files ; ; Prompts for user details & stored in INI file ; ; Launches $Insight and uses INI to auto login ; ; ; ; If no INI exists then prompt to create INI will appear each time ; ; If INI exists but details are blank then Insight will run as normal ; ; ; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;Name files $insight = "x:\InsightCurrent.exe" $InsightLauncher = "\\adl-file\IT\Scripts\AutoIT\Insight Launcher\Insight.exe" $LoginIni = "x:\InsightINI\" & @UserName & ".ini" ;Declair Global $GUISetup, $saveUsernameBox, $savePasswordBox, $butCancel, $butLogin Global $fLogin = False ; New flag to check whether the intial login data was saved <<<<<<<<<<<<<<<<<<< ;Check for actual insight If Not FileExists($insight) Then MsgBox(16, "Insight", "Error network file not found " & @LF & $insight) Exit EndIf If Not FileExists($LoginIni) Then ;Call GUI LoginGUI() ; We only return if the login data was saved ; So we can now.... EndIf RunInsight() ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; GUI controls & Functions ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Func LoginGUI() ;Set GUI $GUISetup = GUICreate("Insight Autologin Setup", 335, 290) WinSetOnTop($GUISetup, "", 1) ;Set Background $GUIBackground = GUICtrlCreatePic("H:\Scripts\AutoIT\Insight Launcher\login.jpg", 0, 0, 335, 290) ;Disble it so can click in input boxes GUICtrlSetState(-1, $GUI_DISABLE) ;Create input boxes $saveUsernameBox = GUICtrlCreateInput("", 89, 130, 185, 21) $savePasswordBox = GUICtrlCreateInput("", 89, 155, 185, 21, BitOR("", $ES_PASSWORD)) $butLogin = GUICtrlCreateButton("Login", 77, 227, 80, 20, $BS_DEFPUSHBUTTON) ; Make button fire on ENTER <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUICtrlSetOnEvent($butLogin, "Save_Details") $butCancel = GUICtrlCreateButton("Cancel", 187, 227, 80) GUICtrlSetOnEvent($butCancel, "On_Close") GUISetOnEvent($GUI_EVENT_CLOSE, "On_Close") ;Show GUI as hidden by default GUISetState(@SW_SHOW) ;Idle around only needed for main GUI $fLogin = False Do Sleep(10) ; 10ms is quite enough ;If Enter (0D) is pressed then save details ; As button fires automatically on ENTER, there is no need for this <<<<<<<<<<<<<<< ;If _IsPressed("0D") Then ; Save_Details() ;EndIf Until $fLogin = True ; If the login key was pressed this will be True and so we exit the loop EndFunc ;==>LoginGUI Func Save_Details() ; Do not delete GUI here or there will be no inputs to read! <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Create INI FileOpen($LoginIni, 10) ; Good idea to do this and create the folder FileClose($LoginIni) ; You should close it again or you may get access problems <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ; You could also use ; DirCreate("x:\InsightINI\) ; It does not hurt to do it again if the folder already exists <<<<<<<<<<<<<<<<<<<<<<< ;Read details $saveUsername = GUICtrlRead($saveUsernameBox) ;Write to INI IniWrite($LoginIni, "LoginDetails", "Username", $saveUsername) ;Read Details $savePassword = GUICtrlRead($savePasswordBox) ;Write to INI IniWrite($LoginIni, "LoginDetails", "Password", $savePassword) ; Deleting the GUI here is fine <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUIDelete($GUISetup) ; If you save the handle then use it rather than the title <<<<<<<<<<<<<<<<<<<<<<< ; Set Login flag so we can quit the loop <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $fLogin = True EndFunc ;==>Save_Details Func RunInsight() ; Start an infinite loop While 1 ; Open insight $PID = Run($insight) ; Wait till insight login screen WinWaitActive("Insight Log in") ; Keep window open wile sending keys SendKeepActive("Insight Log in") ; Get username and password from LoginIni $Username = IniRead($LoginIni, "LoginDetails", "Username", "") $Password = IniRead($LoginIni, "LoginDetails", "Password", "") ;If Username is not blank If Not $Username = "" Then ;Send text (insight will default to password section so tab 4 times first) Send("{TAB 4}" & $Username & "{TAB}" & $Password & "{ENTER}") ;If error received on login (most likley due to incorrect password) If WinWaitActive("Error", "", 15) Then ;Wait for message to close WinWaitClose("Error") ;Close login window Send("!c") ; Close insight ProcessClose($PID) Else ; Login was successful Exit EndIf EndIf ; We get here if the Username is blank or we had an unsuccessful login ; In both cases we re-run the login setup LoginGUI() ; We only get here if the login data was saved ; So go around, restart insight and try to log in again WEnd EndFunc ;==>RunInsight Func On_Close() Switch @GUI_CtrlId ; See which control sent the CLOSE message Case $butCancel ;If it was $butCancel do the following ;GUIDelete($GUISetup) ; Will be done below <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ;Below will set blank INI if cancell pressed. ;~ IniWrite($LoginIni, "LoginDetails", "Username", "") ;~ IniWrite($LoginIni, "LoginDetails", "Password", "") ;~ RunInsight() ContinueCase ; Run the next case now - delete and exit <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Case $GUI_EVENT_CLOSE ; If it was this GUI - we exit GUIDelete($GUISetup) Exit EndSwitch EndFunc ;==>On_Close Please ask if you have any questions - and of course do come back if it does not work. 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...
badapple89 Posted April 4, 2013 Author Share Posted April 4, 2013 Its aliiiiiive!!! And works, thanks so much man .Some things/Questions:So do you know what the issue was, or a multitude of things/bad scripting?Seems its the looping functions that were the savior. They do my head it, even though I've tried to read up on them. Do you have any helpful links to pass on?Also had an idea to change it around. Currently it saves to INI then logs in. But make it run like1. Type Details2. LoginIf sucesful save detailsIf not loop back to Type DetailsMight make it a bit more simple and save re-writing the INI each time.Not sure if there would be any point to this or not though? Thoughts?Func Save_Details() ; Do not delete GUI here or there will be no inputs to read!That totally makes sense, but it was still reading them in my script!?If WinWaitActive("Error", "", 15) Then ;Wait for message to close WinWaitClose("Error") ;Close login window ;Send("!c") ; Close insight ProcessClose($PID) Else ; Login was successful Exit EndIf EndIf ; We get here if the Username is blank or we had an unsuccessful login ; In both cases we re-run the login setup LoginGUI() ; We only get here if the login data was saved ; So go around, restart insight and try to log in again WEndI understand all that (I think). Except for the last two comments. Am I correct in thinking that it works as follows.if login error/blank ini, close insight (also now out of the if statement) then re-launch LoginGUIElse login stressful (also now out of the if statement) then Wend the While1 statement?Thus the comments above the Wend are more like "Only get here if login suspenseful, if not restart from top of While1"$BS_DEFPUSHBUTTON Is awesome thanks for that.There doesn't seem to be one for ESC tho? As in ESC = $GUI_EVENT_CLOSE or similarAlso thanks again for the help!!!!! Link to comment Share on other sites More sharing options...
Moderators Solution Melba23 Posted April 4, 2013 Moderators Solution Share Posted April 4, 2013 badapple89,Basically, you were calling functions from within functions from within the same functions without ever returning - this is known technically as recursion and means you end up in an ever-tightening spiral from which you were never escaping. If you want to learn more I recommend the Recursion tutorial in the Wiki. If you want to rewrite it, then feel free - but I am not doing it for you. You know where we are if you run into problems. I assumed that deleting the GUI was one of the problems you were having - so I cannot explain why you were reading inputs you had deleted. Does this logic flow help explain more clearly what is going on: expandcollapse popup;Check InSight exists ; Check Ini file exists ; If not then run LoginGUI() ; We can only return from this function if the login details have been saved ; As all other options ([X] and Cancel) exit the script ; So as data was saved we run RunInsight() and try to login Func LoginGUI() ; Set up the GUI ; Wait for an event ([X}, Cancel, LogIn ; Pressing LogIn will save data and set the flag to True so we exit the loop and return ; Pressing [X] or Cancel exit the script directly EndFunc ;==>LoginGUI Func Save_Details() ; Create Ini fi it does not exist ; Write to Ini ; Delete the GUI ; Set Login flag to True EndFunc ;==>Save_Details Func RunInsight() ; Start an infinite loop ; Open insight ; Wait till insight login screen ; Get username and password from Ini ; If Username is not blank we try to login ; If error ; Close insight and continue ; If not ; Login was successful so exit ; We get here if the Username is blank or we had an unsuccessful login ; In both cases we re-run LoginGUI() to try and get valid login data ; We can only return from this function if the login details have been saved ; As all other options ([X] and Cancel) exit the script ; We only get here if the login data was saved ; So go around, restart insight and try to log in again EndFunc ;==>RunInsight Func On_Close() ; See which control sent the CLOSE message ; If it was $butCancel do the following ; And then we run the Exit code below ; If $GUI_EVENT_CLOSE ; Exit EndFunc ;==>On_CloseYou should be able to close a GUI by pressing {ESCAPE} by default - look at Opt("GUICloseOnESC") in the Help file. I hope all that 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...
badapple89 Posted May 20, 2013 Author Share Posted May 20, 2013 Notices I never responded. Thanks all is good Can be closed if needed. 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