Swimming_Bird Posted February 23, 2006 Posted February 23, 2006 I've got a GUI within a function that gets called with certain criteria. However whenever i load the script the GUI is loaded. I only want it to open when i want it to, not every time.
greenmachine Posted February 23, 2006 Posted February 23, 2006 Post some code. I can't read your mind.
CyberSlug Posted February 23, 2006 Posted February 23, 2006 Well, don't call GuiSetState(@SW_SHOW) until the criteria is met..... Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
greenmachine Posted February 23, 2006 Posted February 23, 2006 Hmm, you did a better job of reading his mind... What about just not calling the function?
Swimming_Bird Posted February 23, 2006 Author Posted February 23, 2006 It still loads the gui even when i dont call the function. Here's my code expandcollapse popup#include <string.au3> #include <GUIConstants.au3> Global $encpass = 0 Global $password = 0 Global $encrypt = '' Func _createpassword() GUICreate('Password For VPN',310,25) GUICtrlCreateLabel('CSMCC Password',0,0,50,25) Opt('GUICoordMode',2) $passin = GUICtrlCreateInput('',0,-1,200,25,$ES_LEFT+$ES_AUTOHSCROLL+$ES_PASSWORD) $OK = GUICtrlCreateButton('OK',0,-1,60,25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $OK $password = GUICtrlRead($passin) MsgBox(0,'Password',$password) $encpass = _StringEncrypt(1,$password,$encrypt) IniWrite('password.ini','VPN Password','password',$encpass) ExitLoop EndSelect WEnd GUISetState(@SW_HIDE) EndFunc If FileExists('password.ini') Then $encpass = IniRead('password.ini','VPN Password','password',0) If $encpass = 0 Then ;~ _createpassword() Else $password = _StringEncrypt(0,$encpass,$encrypt) EndIf Else ;~ _createpassword() EndIf While 1 WinWaitActive('VPN Client') Send('^o') If WinWait('VPN Client | User Authentication for "CSM"','',10000) = 1 Then ControlSend('VPN Client | User Authentication for "CSM"','password','QWidget4',$password) ControlClick('VPN Client | User Authentication for "CSM"','unnamed','QWidget2') ;~ Else ;~ Sleep(10000) ;~ WinSetState('VPN Client','',@SW_HIDE) EndIf WEnd
greenmachine Posted February 23, 2006 Posted February 23, 2006 Well, I ran your code with all the function calls commented out, and the GUI didn't show up. So, it has to do with the rest of your code calling the function. I think you might want to look at this part especially: If FileExists('password.ini') Then $encpass = IniRead('password.ini','VPN Password','password',0) If $encpass = 0 Then ;~ _createpassword() Else $password = _StringEncrypt(0,$encpass,$encrypt) EndIf Else ;~ _createpassword() EndIf I suspect your iniread isn't working out correctly (or it doesn't exist).
greenmachine Posted February 23, 2006 Posted February 23, 2006 Modified the script so it works. The INIRead getting $encpass was returning a hex string (encrypted) when it worked, but then that made it equal to 0. So I changed it to default to "" and check if $encpass = "". Also, you need $encrypt to equal something, a blank string didn't work for me.... expandcollapse popup#include <string.au3> #include <GUIConstants.au3> Global $encpass = 0 Global $password = 0 Global $encrypt = 'a' Func _createpassword() GUICreate('Password For VPN',310,25) GUICtrlCreateLabel('CSMCC Password',0,0,50,25) Opt('GUICoordMode',2) $passin = GUICtrlCreateInput('',0,-1,200,25,$ES_LEFT+$ES_AUTOHSCROLL+$ES_PASSWORD) $OK = GUICtrlCreateButton('OK',0,-1,60,25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $OK $password = GUICtrlRead($passin) $encpass = _StringEncrypt(1,$password,$encrypt) ExitLoop EndSelect WEnd GUISetState(@SW_HIDE) EndFunc If FileExists('password.ini') Then $encpass = IniRead('password.ini','VPN Password','password',"") If $encpass = "" Then _createpassword() Else $password = _StringEncrypt(0,$encpass,$encrypt) EndIf Else _createpassword() EndIf While 1 WinWaitActive('VPN Client') Send('^o') If WinWait('VPN Client | User Authentication for "CSM"','',10000) = 1 Then ControlSend('VPN Client | User Authentication for "CSM"','password','QWidget4',$password) ControlClick('VPN Client | User Authentication for "CSM"','unnamed','QWidget2') ;~ Else ;~ Sleep(10000) ;~ WinSetState('VPN Client','',@SW_HIDE) EndIf WEnd
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