kees Posted July 4, 2011 Share Posted July 4, 2011 (edited) Hello forum members Question I’ve made a script, NewsReader Switch that’s run fine when I hit F5 (Go) in AutoIt. When I compile the script to exe it runs ok with empty passwords when the passwords are filled in, it will run for few seconds. In AutoIt F5 no errors in the console with or without password Started a half year a go with AutoIt search the forums for answers but this is a little to far for me Any help is appreciated. Here is the code: expandcollapse popup#NoTrayIcon #RequireAdmin #region ;**** Directives created by AutoIt3Wrapper_GUI **** #AutoIt3Wrapper_outfile=NewsServerSwitch.exe #AutoIt3Wrapper_UseUpx=n #endregion ;**** Directives created by AutoIt3Wrapper_GUI **** #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> ; AutoIt Version: 3.3.6.1 Local $InputPass1, $InputPass2, $InputPass3, $InputPass4, $Decrypt1, $Decrypt2, $Decrypt3, $Decrypt4 $sIni = @ScriptDir & "\settings.ini" ;$sIni = @ScriptDir & "\config.ini" ; just for debugging, later on this goes away If Not FileExists($sIni) Then FileWrite($sIni, "") IniWrite($sIni, "NewsServer", "Server1", "") IniWrite($sIni, "NewsServer", "Server2", "") IniWrite($sIni, "NewsServer", "Server3", "") IniWrite($sIni, "NewsServer", "Server4", "") IniWrite($sIni, "Username", "User1", "") IniWrite($sIni, "Username", "User2", "") IniWrite($sIni, "Username", "User3", "") IniWrite($sIni, "Username", "User4", "") IniWrite($sIni, "Passwords", "Password01", "") IniWrite($sIni, "Passwords", "Password02", "") IniWrite($sIni, "Passwords", "Password03", "") IniWrite($sIni, "Passwords", "Password04", "") IniWrite($sIni, "Secure Sockets", "SSL1", 4) IniWrite($sIni, "Secure Sockets", "SSL2", 4) IniWrite($sIni, "Secure Sockets", "SSL3", 4) IniWrite($sIni, "Secure Sockets", "SSL4", 1) IniWrite($sIni, "Ports", "Portnumber1", "119") IniWrite($sIni, "Ports", "Portnumber2", "119") IniWrite($sIni, "Ports", "Portnumber3", "119") IniWrite($sIni, "Ports", "Portnumber4", "443") EndIf $current_server1 = IniRead($sIni, "NewsServer", "Server1", "") $current_server2 = IniRead($sIni, "NewsServer", "Server2", "") $current_server3 = IniRead($sIni, "NewsServer", "Server3", "") $current_server4 = IniRead($sIni, "NewsServer", "Server4", "") $current_user1 = IniRead($sIni, "Username", "User1", "") $current_user2 = IniRead($sIni, "Username", "User2", "") $current_user3 = IniRead($sIni, "Username", "User3", "") $current_user4 = IniRead($sIni, "Username", "User4", "") $current_port1 = IniRead($sIni, "Ports", "Portnumber1", "119") $current_port2 = IniRead($sIni, "Ports", "Portnumber2", "119") $current_port3 = IniRead($sIni, "Ports", "Portnumber3", "119") $current_port4 = IniRead($sIni, "Ports", "Portnumber4", "443") $current_password1 = IniRead($sIni, "Passwords", "Password01", "") If $current_password1 == "" Then GUICtrlRead($InputPass1) MsgBox(0, "NO Password 1", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode1 = _Base64Decode($current_password1) Dim $Decrypt1 = BinaryToString($Decode1) ; Show decoded in $InputPass1 masked $ES_PASSWORD MsgBox(0, "Password Found 1", $Decrypt1, 1) ; just for debugging, later on this goes away EndIf $current_password2 = IniRead($sIni, "Passwords", "Password02", "") If $current_password2 == "" Then GUICtrlRead($InputPass2) MsgBox(0, "NO Password 2", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode2 = _Base64Decode($current_password2) Dim $Decrypt2 = BinaryToString($Decode2) MsgBox(0, "Password Found 2", $Decrypt2, 2) ; just for debugging, later on this goes away EndIf $current_password3 = IniRead($sIni, "Passwords", "Password03", "") If $current_password3 == "" Then GUICtrlRead($InputPass3) MsgBox(0, "NO Password 3", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode3 = _Base64Decode($current_password3) Dim $Decrypt3 = BinaryToString($Decode3) MsgBox(0, "Password Found 3", $Decrypt3, 1) ; just for debugging, later on this goes away EndIf $current_password4 = IniRead($sIni, "Passwords", "Password04", "") If $current_password4 == "" Then GUICtrlRead($InputPass4) MsgBox(0, "NO Password 4", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode4 = _Base64Decode($current_password4) Dim $Decrypt4 = BinaryToString($Decode4) MsgBox(0, "Password Found 4", $Decrypt4, 1) ; just for debugging, later on this goes away EndIf $NSSGUI = GUICreate("News Server Switch", 850, 500, 400, 200) ; NewsReader one $ServerLabel1 = GUICtrlCreateLabel("Server address", 20, 16, 74, 17) $Server1 = GUICtrlCreateInput("" & $current_server1, 20, 32, 150, 21) $UserNamelabel1 = GUICtrlCreateLabel("User name", 216, 16, 81, 17) $UserName1 = GUICtrlCreateInput("" & $current_user1, 216, 32, 150, 21) $Passwordlabel1 = GUICtrlCreateLabel("Password", 411, 16, 65, 17) $InputPass1 = GUICtrlCreateInput("" & $Decrypt1, 411, 32, 150, 21, $ES_PASSWORD) $SSLLabel1 = GUICtrlCreateLabel("SSL", 588, 16, 24, 17) $SSL1 = GUICtrlCreateCheckbox("", 592, 34, 17, 17) GUICtrlSetState($SSL1, IniRead($sIni, "Secure Sockets", "SSL1", 1)) $portLabel1 = GUICtrlCreateLabel("Port", 637, 16, 29, 17) $Port1 = GUICtrlCreateInput("" & $current_port1, 637, 32, 57, 21) $ok1 = GUICtrlCreateButton("OK", 713, 30, 35, 25, $WS_GROUP) ; NewsReader two $ServerLabel2 = GUICtrlCreateLabel("Server address", 20, 67, 74, 17) $Server2 = GUICtrlCreateInput("" & $current_server2, 20, 83, 150, 21) $UserNamelabel2 = GUICtrlCreateLabel("User name", 216, 67, 81, 17) $UserName2 = GUICtrlCreateInput("" & $current_user2, 216, 83, 150, 21) $Passwordlabel2 = GUICtrlCreateLabel("Password", 411, 67, 65, 17) $InputPass2 = GUICtrlCreateInput("" & $Decrypt2, 411, 83, 150, 21, $ES_PASSWORD) $SSLLabel2 = GUICtrlCreateLabel("SSL", 588, 67, 24, 17) $SSL2 = GUICtrlCreateCheckbox("", 592, 85, 17, 17) GUICtrlSetState($SSL2, IniRead($sIni, "Secure Sockets", "SSL2", 1)) $portLabel2 = GUICtrlCreateLabel("Port", 637, 67, 29, 17) $Port2 = GUICtrlCreateInput("" & $current_port2, 637, 83, 57, 21) $ok2 = GUICtrlCreateButton("OK", 713, 81, 35, 25, $WS_GROUP) ; NewsReader three $ServerLabel3 = GUICtrlCreateLabel("Server address", 18, 117, 74, 17) $Server3 = GUICtrlCreateInput("" & $current_server3, 20, 133, 150, 21) $UserNamelabel3 = GUICtrlCreateLabel("User name", 216, 117, 81, 17) $UserName3 = GUICtrlCreateInput("" & $current_user3, 216, 133, 150, 21) $Passwordlabel3 = GUICtrlCreateLabel("Password", 411, 117, 65, 17) $InputPass3 = GUICtrlCreateInput("" & $Decrypt3, 411, 133, 150, 21, $ES_PASSWORD) $SSLLabel3 = GUICtrlCreateLabel("SSL", 588, 117, 24, 17) $SSL3 = GUICtrlCreateCheckbox("", 592, 135, 17, 17) GUICtrlSetState($SSL3, IniRead($sIni, "Secure Sockets", "SSL3", 1)) $portLabel3 = GUICtrlCreateLabel("Port", 637, 117, 29, 17) $Port3 = GUICtrlCreateInput("" & $current_port3, 637, 133, 57, 21) $ok3 = GUICtrlCreateButton("OK", 713, 131, 35, 25, $WS_GROUP) ; NewsReader four $ServerLabel4 = GUICtrlCreateLabel("Server address", 20, 168, 74, 17) $Server4 = GUICtrlCreateInput("" & $current_server4, 20, 184, 150, 21) $UserNamelabel4 = GUICtrlCreateLabel("User name", 216, 168, 81, 17) $UserName4 = GUICtrlCreateInput("" & $current_user4, 216, 184, 150, 21) $Passwordlabel4 = GUICtrlCreateLabel("Password", 411, 168, 65, 17) $InputPass4 = GUICtrlCreateInput("" & $Decrypt4, 411, 184, 150, 21, $ES_PASSWORD) $SSLLabel4 = GUICtrlCreateLabel("SSL", 588, 168, 24, 17) $SSL4 = GUICtrlCreateCheckbox("", 592, 186, 17, 17) GUICtrlSetState($SSL4, IniRead($sIni, "Secure Sockets", "SSL4", 1)) $portLabel4 = GUICtrlCreateLabel("Port", 637, 168, 29, 17) $Port4 = GUICtrlCreateInput("" & $current_port4, 637, 184, 57, 21) $ok4 = GUICtrlCreateButton("OK", 713, 182, 35, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $ok1 _nntp_server1() Case $ok2 _nntp_server2() Case $ok3 _nntp_server3() Case $ok4 _nntp_server4() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func _nntp_server1() ; Password, must encoded Base64 $Encrypt1 = _Base64Encode(GUICtrlRead($InputPass1)) $Passw1 = "@ByteArray(" & $Encrypt1 & ")" ; User $User1 = "@ByteArray(" & GUICtrlRead($UserName1) & ")" ;SSL If GUICtrlRead($SSL1) = 4 Then $State1 = "false" Else $State1 = "true" EndIf RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow") RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "server", "REG_SZ", GUICtrlRead($Server1)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "user", "REG_SZ", ($User1)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "pass", "REG_SZ", ($Passw1)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "ssl", "REG_SZ", ($State1)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "port", "REG_DWORD", GUICtrlRead($Port1)) IniWrite($sIni, "NewsServer", "Server1", GUICtrlRead($Server1)) IniWrite($sIni, "Username", "User1", GUICtrlRead($UserName1)) IniWrite($sIni, "Passwords", "Password01", $Encrypt1) ; Saved encoded Base64 IniWrite($sIni, "Secure Sockets", "SSL1", GUICtrlRead($SSL1)) IniWrite($sIni, "Ports", "Portnumber1", GUICtrlRead($Port1)) MsgBox(0, "News Server Switch1", "Ready!", 1) EndFunc ;==>_nntp_server1 Func _nntp_server2() ; Password $Encrypt2 = _Base64Encode(GUICtrlRead($InputPass2)) $Passw2 = "@ByteArray(" & $Encrypt2 & ")" ; User $User2 = "@ByteArray(" & GUICtrlRead($UserName2) & ")" ;SSL If GUICtrlRead($SSL2) = 4 Then $State2 = "false" Else $State2 = "true" EndIf RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow") RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "server", "REG_SZ", GUICtrlRead($Server2)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "user", "REG_SZ", ($User2)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "pass", "REG_SZ", ($Passw2)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "ssl", "REG_SZ", ($State2)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "port", "REG_DWORD", GUICtrlRead($Port2)) IniWrite($sIni, "NewsServer", "Server2", GUICtrlRead($Server2)) IniWrite($sIni, "Username", "User2", GUICtrlRead($UserName2)) IniWrite($sIni, "Passwords", "Password02", $Encrypt2) IniWrite($sIni, "Secure Sockets", "SSL2", GUICtrlRead($SSL2)) IniWrite($sIni, "Ports", "Portnumber2", GUICtrlRead($Port2)) MsgBox(0, "News Server Switch2", "Ready!", 2) EndFunc ;==>_nntp_server2 Func _nntp_server3() ; Password $Encrypt3 = _Base64Encode(GUICtrlRead($InputPass3)) $Passw3 = "@ByteArray(" & $Encrypt3 & ")" ; User $User3 = "@ByteArray(" & GUICtrlRead($UserName3) & ")" ;SSL If GUICtrlRead($SSL3) = 4 Then $State3 = "false" Else $State3 = "true" EndIf RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow") RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "server", "REG_SZ", GUICtrlRead($Server3)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "user", "REG_SZ", ($User3)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "pass", "REG_SZ", ($Passw3)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "ssl", "REG_SZ", ($State3)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "port", "REG_DWORD", GUICtrlRead($Port3)) IniWrite($sIni, "NewsServer", "Server3", GUICtrlRead($Server3)) IniWrite($sIni, "Username", "User3", GUICtrlRead($UserName3)) IniWrite($sIni, "Passwords", "Password03", $Encrypt3) IniWrite($sIni, "Secure Sockets", "SSL3", GUICtrlRead($SSL3)) IniWrite($sIni, "Ports", "Portnumber3", GUICtrlRead($Port3)) MsgBox(0, "News Server Switch 3", "Ready!", 2) EndFunc ;==>_nntp_server3 Func _nntp_server4() ; Password $Encrypt4 = _Base64Encode(GUICtrlRead($InputPass4)) $Passw4 = "@ByteArray(" & $Encrypt4 & ")" ; User $User4 = "@ByteArray(" & GUICtrlRead($UserName4) & ")" ;SSL If GUICtrlRead($SSL3) = 4 Then $State4 = "false" Else $State4 = "true" EndIf RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow") RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "server", "REG_SZ", GUICtrlRead($Server4)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "user", "REG_SZ", ($User4)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "pass", "REG_SZ", ($Passw4)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "ssl", "REG_SZ", ($State4)) RegWrite("HKEY_CURRENT_USER\Software\NewsNow\NewsNow", "port", "REG_DWORD", GUICtrlRead($Port4)) IniWrite($sIni, "NewsServer", "Server4", GUICtrlRead($Server4)) IniWrite($sIni, "Username", "User4", GUICtrlRead($UserName4)) IniWrite($sIni, "Passwords", "Password04", $Encrypt4) IniWrite($sIni, "Secure Sockets", "SSL4", GUICtrlRead($SSL4)) IniWrite($sIni, "Ports", "Portnumber4", GUICtrlRead($Port4)) MsgBox(0, "News Server Switch 4", "Ready!", 2) EndFunc ;==>_nntp_server4 ; ---------------------------------------------------------------------------------------------- ; Base64 Machine Code ; Purpose: Provide Machine Code Version of Base64 Encoder/Decoder In AutoIt ; Author: Ward ; Date: November 2010 ; Url: http://www.autoitscript.com/forum/topic/121985-autoit-machine-code-algorithm-collection/ ; ---------------------------------------------------------------------------------------------- Func _Base64Decode($Data) Local $Opcode = "0xC81000005356578365F800E8500000003EFFFFFF3F3435363738393A3B3C3DFFFFFF00FFFFFF000102030405060708090A0B0C0D0E0F10111213141516171819FFFFFFFFFFFF1A1B1C1D1E1F202122232425262728292A2B2C2D2E2F303132338F45F08B7D0C8B5D0831D2E9910000008365FC00837DFC047D548A034384C0750383EA033C3D75094A803B3D75014AB00084C0751A837DFC047D0D8B75FCC64435F400FF45FCEBED6A018F45F8EB1F3C2B72193C7A77150FB6F083EE2B0375F08A068B75FC884435F4FF45FCEBA68D75F4668B06C0E002C0EC0408E08807668B4601C0E004C0EC0208E08847018A4602C0E00624C00A46038847028D7F038D5203837DF8000F8465FFFFFF89D05F5E5BC9C21000" Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) Local $Ouput = DllStructCreate("byte[" & BinaryLen($Data) & "]") Local $Ret = DllCall("user32.dll", "int", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "str", $Data, _ "ptr", DllStructGetPtr($Ouput), _ "int", 0, _ "int", 0) Return BinaryMid(DllStructGetData($Ouput, 1), 1, $Ret[0]) EndFunc ;==>_Base64Decode Func _Base64Encode($Data, $LineBreak = 76) Local $Opcode = "0x5589E5FF7514535657E8410000004142434445464748494A4B4C4D4E4F505152535455565758595A6162636465666768696A6B6C6D6E6F707172737475767778797A303132333435363738392B2F005A8B5D088B7D108B4D0CE98F0000000FB633C1EE0201D68A06880731C083F901760C0FB6430125F0000000C1E8040FB63383E603C1E60409C601D68A0688470183F90176210FB6430225C0000000C1E8060FB6730183E60FC1E60209C601D68A06884702EB04C647023D83F90276100FB6730283E63F01D68A06884703EB04C647033D8D5B038D7F0483E903836DFC04750C8B45148945FC66B80D0A66AB85C90F8F69FFFFFFC607005F5E5BC9C21000" Local $CodeBuffer = DllStructCreate("byte[" & BinaryLen($Opcode) & "]") DllStructSetData($CodeBuffer, 1, $Opcode) $Data = Binary($Data) Local $Input = DllStructCreate("byte[" & BinaryLen($Data) & "]") DllStructSetData($Input, 1, $Data) $LineBreak = Floor($LineBreak / 4) * 4 Local $OputputSize = Ceiling(BinaryLen($Data) * 4 / 3) $OputputSize = $OputputSize + Ceiling($OputputSize / $LineBreak) * 2 + 4 Local $Ouput = DllStructCreate("char[" & $OputputSize & "]") DllCall("user32.dll", "none", "CallWindowProc", "ptr", DllStructGetPtr($CodeBuffer), _ "ptr", DllStructGetPtr($Input), _ "int", BinaryLen($Data), _ "ptr", DllStructGetPtr($Ouput), _ "uint", $LineBreak) Return DllStructGetData($Ouput, 1) EndFunc ;==>_Base64Encode Thanks in advance Edited: Copy and paste error $current_password4 = IniRead($sIni, "Passwords", "Password04", "") Edited July 5, 2011 by kees Link to comment Share on other sites More sharing options...
JohnOne Posted July 5, 2011 Share Posted July 5, 2011 (edited) Perhaps adding some error checking will reveal the answer to you, at least narrow down where the problem is occurring. EDIT: Also take time to notice how it is compiling if you run x64 cpu, it might be that you have to compile 32. Edited July 5, 2011 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
kees Posted July 5, 2011 Author Share Posted July 5, 2011 (edited) Ok more details: compiled x32 I’ve the script compiled on Win XP SP3 and Win 7 SP1 but on both machines it crash with more than two passwords. The error arises by adding a password, with one or two passwords it still runs ok with three and more it will crash In this part of the script $current_password1 = IniRead($sIni, "Passwords", "Password01", "") If $current_password1 == "" Then GUICtrlRead($InputPass1) MsgBox(0, "NO Password 1", "No Password Found!", 1) Else Dim $Decode1 = _Base64Decode($current_password1) Dim $Decrypt1 = BinaryToString($Decode1) ; Show decoded in $InputPass1 masked $ES_PASSWORD MsgBox(0, "Password Found 1", $Decrypt1, 1) EndIf I can’t let read direct the ini file because this is a encoded password,when the Ok button is pushed the encoded saved password get's encoded again, so this won't work: $InputPass1 = GUICtrlCreateInput("" & $current_password1, 411, 32, 150, 21, $ES_PASSWORD) It must decode again like $InputPass1 = GUICtrlCreateInput("" & $Decrypt1, 411, 32, 150, 21, $ES_PASSWORD) I’ve tried $InputPass1 = GUICtrlCreateInput("" & $Decode1, 411, 32, 150, 21) This will crash also settings.ini entered Password01 is here:123456 [NewsServer] Server1=news.today.com Server2= Server3= Server4= [Username] User1=kees User2= User3= User4= [Passwords] Password01=MTIzNDU2 Password02= Password03= Password04= [Secure Sockets] SSL1=4 SSL2=4 SSL3=4 SSL4=1 [Ports] Portnumber1=119 Portnumber2=119 Portnumber3=119 Portnumber4=443 Maybe it's a memory thing to much to decode when the script starts up with three or more passwords are in the ini file Edit: I've tried differed Base64 encoder / decoder Current: tried and this one all will crash Edited July 5, 2011 by kees Link to comment Share on other sites More sharing options...
jaberwacky Posted July 5, 2011 Share Posted July 5, 2011 (edited) An issue that I have observed with your code is this: expandcollapse popup$current_password1 = IniRead($sIni, "Passwords", "Password01", "") If $current_password1 == "" Then GUICtrlRead($InputPass1) MsgBox(0, "NO Password 1", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode1 = _Base64Decode($current_password1) Dim $Decrypt1 = BinaryToString($Decode1) ; Show decoded in $InputPass1 masked $ES_PASSWORD MsgBox(0, "Password Found 1", $Decrypt1, 1) ; just for debugging, later on this goes away EndIf $current_password2 = IniRead($sIni, "Passwords", "Password02", "") If $current_password2 == "" Then GUICtrlRead($InputPass2) MsgBox(0, "NO Password 2", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode2 = _Base64Decode($current_password2) Dim $Decrypt2 = BinaryToString($Decode2) MsgBox(0, "Password Found 2", $Decrypt2, 2) ; just for debugging, later on this goes away EndIf $current_password3 = IniRead($sIni, "Passwords", "Password03", "") If $current_password3 == "" Then GUICtrlRead($InputPass3) MsgBox(0, "NO Password 3", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode3 = _Base64Decode($current_password3) Dim $Decrypt3 = BinaryToString($Decode3) MsgBox(0, "Password Found 3", $Decrypt3, 1) ; just for debugging, later on this goes away EndIf $current_password4 = IniRead($sIni, "Passwords", "Password01", "") If $current_password4 == "" Then GUICtrlRead($InputPass4) MsgBox(0, "NO Password 4", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode4 = _Base64Decode($current_password4) Dim $Decrypt4 = BinaryToString($Decode4) MsgBox(0, "Password Found 4", $Decrypt4, 1) ; just for debugging, later on this goes away EndIf This section of code makes GUICtrlReads for a GUI that does not yet exist. Edited July 5, 2011 by LaCastiglione Helpful Posts and Websites: AutoIt3 Variables and Function Parameters MHz | AutoIt Wiki | Using the GUIToolTip UDF BrewManNH | Can't find what you're looking for on the Forum? Link to comment Share on other sites More sharing options...
kees Posted July 5, 2011 Author Share Posted July 5, 2011 (edited) @LaCastiglioneWhen I put the piece of code under $ok4 = GUICtrlCreateButton("OK", 713, 182, 35, 25, $WS_GROUP) GUISetState(@SW_SHOW)HERE........ in this placeWhile 1 $nMsg = GUIGetMsg() Switch $nMsg Case $ok1 _nntp_server1() Case $ok2 _nntp_server2() Case $ok3 _nntp_server3() Case $ok4 _nntp_server4() Case $GUI_EVENT_CLOSE Exit EndSwitch WEndthe password inputbox stays emptyI did this the first time ...that's why I put this in the code:Local $InputPass1, $InputPass2, $InputPass3, $InputPass4, $Decrypt1, $Decrypt2, $Decrypt3, $Decrypt4EditCopy and paste error (but this is not the issue....)$current_password4 = IniRead($sIni, "Passwords", "Password01", "")must be$current_password4 = IniRead($sIni, "Passwords", "Password04", "") Edited July 5, 2011 by kees Link to comment Share on other sites More sharing options...
kees Posted July 5, 2011 Author Share Posted July 5, 2011 (edited) @LaCastiglione You bring me on other thoughts Don't know if it's correct to do in AutoIt... but it looks like it's ok now I let you now first testing on differed machines expandcollapse popup$current_password1 = IniRead($sIni, "Passwords", "Password01", "") $current_password2 = IniRead($sIni, "Passwords", "Password02", "") $current_password3 = IniRead($sIni, "Passwords", "Password03", "") $current_password4 = IniRead($sIni, "Passwords", "Password04", "") $NSSGUI = GUICreate("News Server Switch", 850, 500, 400, 200) ; NewsReader one $ServerLabel1 = GUICtrlCreateLabel("Server address", 20, 16, 74, 17) $Server1 = GUICtrlCreateInput("" & $current_server1, 20, 32, 150, 21) $UserNamelabel1 = GUICtrlCreateLabel("User name", 216, 16, 81, 17) $UserName1 = GUICtrlCreateInput("" & $current_user1, 216, 32, 150, 21) $Passwordlabel1 = GUICtrlCreateLabel("Password", 411, 16, 65, 17) If $current_password1 == "" Then $InputPass1 = GUICtrlCreateInput("" , 411, 32, 150, 21, $ES_PASSWORD) MsgBox(0, "NO Password 1", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode1 = _Base64Decode($current_password1) Dim $Decrypt1 = BinaryToString($Decode1) ; Show decoded in $InputPass1 masked $ES_PASSWORD $InputPass1 = GUICtrlCreateInput("" & $Decrypt1, 411, 32, 150, 21, $ES_PASSWORD) MsgBox(0, "Password Found 1", $Decrypt1, 1) ; just for debugging, later on this goes away EndIf $SSLLabel1 = GUICtrlCreateLabel("SSL", 588, 16, 24, 17) $SSL1 = GUICtrlCreateCheckbox("", 592, 34, 17, 17) GUICtrlSetState($SSL1, IniRead($sIni, "Secure Sockets", "SSL1", 1)) $portLabel1 = GUICtrlCreateLabel("Port", 637, 16, 29, 17) $Port1 = GUICtrlCreateInput("" & $current_port1, 637, 32, 57, 21) $ok1 = GUICtrlCreateButton("OK", 713, 30, 35, 25, $WS_GROUP) ; NewsReader two $ServerLabel2 = GUICtrlCreateLabel("Server address", 20, 67, 74, 17) $Server2 = GUICtrlCreateInput("" & $current_server2, 20, 83, 150, 21) $UserNamelabel2 = GUICtrlCreateLabel("User name", 216, 67, 81, 17) $UserName2 = GUICtrlCreateInput("" & $current_user2, 216, 83, 150, 21) $Passwordlabel2 = GUICtrlCreateLabel("Password", 411, 67, 65, 17) If $current_password2 == "" Then $InputPass2 = GUICtrlCreateInput("", 411, 83, 150, 21, $ES_PASSWORD) MsgBox(0, "NO Password 2", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode2 = _Base64Decode($current_password2) Dim $Decrypt2 = BinaryToString($Decode2) $InputPass2 = GUICtrlCreateInput("" & $Decrypt2, 411, 83, 150, 21, $ES_PASSWORD) MsgBox(0, "Password Found 2", $Decrypt2, 2) ; just for debugging, later on this goes away EndIf $SSLLabel2 = GUICtrlCreateLabel("SSL", 588, 67, 24, 17) $SSL2 = GUICtrlCreateCheckbox("", 592, 85, 17, 17) GUICtrlSetState($SSL2, IniRead($sIni, "Secure Sockets", "SSL2", 1)) $portLabel2 = GUICtrlCreateLabel("Port", 637, 67, 29, 17) $Port2 = GUICtrlCreateInput("" & $current_port2, 637, 83, 57, 21) $ok2 = GUICtrlCreateButton("OK", 713, 81, 35, 25, $WS_GROUP) ; NewsReader three $ServerLabel3 = GUICtrlCreateLabel("Server address", 18, 117, 74, 17) $Server3 = GUICtrlCreateInput("" & $current_server3, 20, 133, 150, 21) $UserNamelabel3 = GUICtrlCreateLabel("User name", 216, 117, 81, 17) $UserName3 = GUICtrlCreateInput("" & $current_user3, 216, 133, 150, 21) $Passwordlabel3 = GUICtrlCreateLabel("Password", 411, 117, 65, 17) If $current_password3 == "" Then $InputPass3 = GUICtrlCreateInput("", 411, 133, 150, 21, $ES_PASSWORD) MsgBox(0, "NO Password 3", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode3 = _Base64Decode($current_password3) Dim $Decrypt3 = BinaryToString($Decode3) $InputPass3 = GUICtrlCreateInput("" & $Decrypt3, 411, 133, 150, 21, $ES_PASSWORD) MsgBox(0, "Password Found 3", $Decrypt3, 1) ; just for debugging, later on this goes away EndIf $SSLLabel3 = GUICtrlCreateLabel("SSL", 588, 117, 24, 17) $SSL3 = GUICtrlCreateCheckbox("", 592, 135, 17, 17) GUICtrlSetState($SSL3, IniRead($sIni, "Secure Sockets", "SSL3", 1)) $portLabel3 = GUICtrlCreateLabel("Port", 637, 117, 29, 17) $Port3 = GUICtrlCreateInput("" & $current_port3, 637, 133, 57, 21) $ok3 = GUICtrlCreateButton("OK", 713, 131, 35, 25, $WS_GROUP) ; NewsReader four $ServerLabel4 = GUICtrlCreateLabel("Server address", 20, 168, 74, 17) $Server4 = GUICtrlCreateInput("" & $current_server4, 20, 184, 150, 21) $UserNamelabel4 = GUICtrlCreateLabel("User name", 216, 168, 81, 17) $UserName4 = GUICtrlCreateInput("" & $current_user4, 216, 184, 150, 21) $Passwordlabel4 = GUICtrlCreateLabel("Password", 411, 168, 65, 17) If $current_password4 == "" Then $InputPass4 = GUICtrlCreateInput("", 411, 184, 150, 21, $ES_PASSWORD) MsgBox(0, "NO Password 4", "No Password Found!", 1) ; just for debugging, later on this goes away Else Dim $Decode4 = _Base64Decode($current_password4) Dim $Decrypt4 = BinaryToString($Decode4) $InputPass4 = GUICtrlCreateInput("" & $Decrypt4, 411, 184, 150, 21, $ES_PASSWORD) MsgBox(0, "Password Found 4", $Decrypt4, 1) ; just for debugging, later on this goes away EndIf $SSLLabel4 = GUICtrlCreateLabel("SSL", 588, 168, 24, 17) $SSL4 = GUICtrlCreateCheckbox("", 592, 186, 17, 17) GUICtrlSetState($SSL4, IniRead($sIni, "Secure Sockets", "SSL4", 1)) $portLabel4 = GUICtrlCreateLabel("Port", 637, 168, 29, 17) $Port4 = GUICtrlCreateInput("" & $current_port4, 637, 184, 57, 21) $ok4 = GUICtrlCreateButton("OK", 713, 182, 35, 25, $WS_GROUP) GUISetState(@SW_SHOW) now I can let this away Local $InputPass1, $InputPass2, $InputPass3, $InputPass4, $Decrypt1, $Decrypt2, $Decrypt3, $Decrypt4 One more question about the ini file do I have to write: IniWrite($sIni, "Secure Sockets", "SSL1", 4) or IniWrite($sIni, "Secure Sockets", "SSL1", "4") This is used for the checkbox "SSL" 4 = unchecked 1 = checked Edited July 5, 2011 by kees Link to comment Share on other sites More sharing options...
Tvern Posted July 5, 2011 Share Posted July 5, 2011 do I have to write: IniWrite($sIni, "Secure Sockets", "SSL1", 4) or IniWrite($sIni, "Secure Sockets", "SSL1", "4") Both result in a string when read back with IniRead, so while the second syntax is more correct, there is no functional difference. When reading the value you need be aware that you are reading a string, even if you wrote a number. This can lead to unexpected results, so if you are trying to IniRead a number it's best to convert it to a Number datatype using Number() Here's an example: Global $sIniName = @TempDir & "\VarTypeTest.ini" IniWrite($sIniName,"Values","Number",4) ;Store 4 as a number IniWrite($sIniName,"Values","String","4") ;Store 4 as a string Global $vNumber = IniRead($sIniName,"Values","Number",0) ;Read the number Global $vString = IniRead($sIniName,"Values","String",0) ;Read the string FileDelete($sIniName) ConsoleWrite("$vNumber is a " & VarGetType($vNumber) & " with the value of " & $vNumber & @CRLF) ;This is now a string too! ConsoleWrite("$vString is a " & VarGetType($vString) & " with the value of " & $vString & @CRLF) ;This was always a string If $vNumber > "10" Then ;errors can happen when trying to do numeric comparisons with strings ConsoleWrite("The string " & $vNumber & " is bigger than 10" & @CRLF) Else ConsoleWrite("The string " & $vNumber & " is not bigger than 10" & @CRLF) EndIf If Number($vNumber) > "10" Then ;when at least one of the strings is converted to a number autoit will do a proper numeric comparison. (just to be sure it's best to never use strings in numeric comparisons) ConsoleWrite("The number " & $vNumber & " is bigger than 10" & @CRLF) Else ConsoleWrite("The number " & $vNumber & " is not bigger than 10" & @CRLF) EndIf Link to comment Share on other sites More sharing options...
kees Posted July 6, 2011 Author Share Posted July 6, 2011 @Tvern Thanks for the lessons Greatly appreciated Greetings, Kees 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