beardeus Posted September 26, 2015 Share Posted September 26, 2015 (edited) Hi,So I just began using AutoIT yesterday to automate our installers at work. Let me first say that AutoIT is awesome and I'm wondering why I didn't start using this so long ago. Well, I have completely automated the installers but it enters the same text every time it runs. I want to be able to have .ini files that can be read and inserted into text boxes of the installer. I have looked at the help section about IniReadSection and IniRead and IniWrite but frankly I am so stumped. I would post code but I literally don't have any for reading from the file and then writing the data. Any direction would be great as I have not found anything that clearly explains this.If I had an example of just reading from an .ini and placing that text into one text box it would be a huge help! Edited September 29, 2015 by beardeus Link to comment Share on other sites More sharing options...
Moderators JLogan3o13 Posted September 26, 2015 Moderators Share Posted September 26, 2015 Hi, beardus, welcome to the forum. The basic syntax for reading from an ini would be something like this:$sINI = <path to ini file> $myText = IniRead($sINI, <Section Name>, <Key Name>, "")You could then use ControlSend to send the string to the text box (without knowing what you're installing, or seeing the text box control, it is a little difficult to be more specific).In addition to this, please keep in mind that most installers support silent switches. If the application you're installing supports this, it will definitely save you some headache from trying to manipulate the GUI. You might check into this option if it is a piece of commercial software. "Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball How to get your question answered on this forum! Link to comment Share on other sites More sharing options...
beardeus Posted September 26, 2015 Author Share Posted September 26, 2015 Hi Logan,Thank you! Do I need to know the name of the text box to send text to it? Can I do it based on what the UI says? Link to comment Share on other sites More sharing options...
beardeus Posted September 26, 2015 Author Share Posted September 26, 2015 Let me give a little more info. I work for a software company that develops eDiscovery software for litigation purposes and the part of the installer I'm on has textboxes for a "Domain\UserID", "Password", along with some database credentials. Link to comment Share on other sites More sharing options...
l3ill Posted September 26, 2015 Share Posted September 26, 2015 (edited) Hi Beardeus,Welcome to the forums !here is little prog I have been working on that may help you..expandcollapse popup#include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <MsgBoxConstants.au3> #include <FTPEx.au3> Local $HostName Local $UserName Local $PassWord Local $testConn $Form1 = GUICreate("FTP Login Credentials", 357, 162, 192, 124) $HostNameB = GUICtrlCreateInput($HostName, 40, 24, 161, 21) $UserNameB = GUICtrlCreateInput($UserName, 40, 56, 161, 21) $PassWordB = GUICtrlCreateInput($PassWord, 40, 88, 161, 21) $Save = GUICtrlCreateButton("Save", 232, 24, 73, 25) GUICtrlSetTip(-1, "Saves login Info to INI File") $Load = GUICtrlCreateButton("Load", 232, 56, 73, 25) GUICtrlSetTip(-1, "Loads Previously Saved login Info from INI File") $clear = GUICtrlCreateButton("Clear", 232, 88, 73, 25) GUICtrlSetTip(-1, "Deletes any Previously saved INI Files") $testConn = GUICtrlCreateButton("Test Connection", 132, 120, 90, 25) GUICtrlSetTip(-1, "Test your Login Credentials") GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Load _iniLoad() Case $Save _iniSave() Case $clear _clearAll() Case $testConn _testConn() EndSwitch WEnd Assign Func _clearAll() GUICtrlSetData($HostNameB, "") GUICtrlSetData($UserNameB, "") GUICtrlSetData($PassWordB, "") $iniFile = @ScriptDir & "\login.ini" If FileExists($iniFile) Then FileDelete($iniFile) MsgBox(4096, $iniFile, $iniFile & ": Was Deleted", 2) Else MsgBox(4096, $iniFile, $iniFile & ": Does not Exist", 2) EndIf EndFunc ;==>_clearAll Func _iniLoad() If FileExists(@ScriptDir & "\login.ini") Then $HostName = IniRead(@ScriptDir & "\login.ini", "login", "HostName", "Default Value") $UserName = IniRead(@ScriptDir & "\login.ini", "login", "UserName", "Default Value") $PassWord = IniRead(@ScriptDir & "\login.ini", "login", "PassWord", "Default Value") GUICtrlSetData($HostNameB, $HostName) GUICtrlSetData($UserNameB, $UserName) GUICtrlSetData($PassWordB, $PassWord) Else MsgBox(16, "No File", "File Not Found") EndIf EndFunc ;==>_iniLoad Func _iniSave() $HostName = GUICtrlRead($HostNameB) $UserName = GUICtrlRead($UserNameB) $PassWord = GUICtrlRead($PassWordB) IniWrite(@ScriptDir & "\login.ini", "login", "HostName", $HostName) IniWrite(@ScriptDir & "\login.ini", "login", "UserName", $UserName) IniWrite(@ScriptDir & "\login.ini", "login", "PassWord", $PassWord) EndFunc ;==>_iniSave Func _testConn() _iniSave() Local $hOpen = _FTP_Open('MyFTP Control') Local $hConn = _FTP_Connect($hOpen, $HostName, $UserName, $PassWord) If $hConn = 0 Then MsgBox(0, "FTP Connection", "Connection not possible", 1) EndIf If $hConn > 0 Then MsgBox(0, "FTP Connection", "FTP Connected Successfully", 1) EndIf Local $Ftpc = _FTP_Close($hConn) Local $Ftpo = _FTP_Close($hOpen) EndFunc ;==>_testConn Edited September 26, 2015 by l3ill fixed last endif ;-) ahmeddzcom 1 My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
ahmeddzcom Posted September 26, 2015 Share Posted September 26, 2015 Must Delete Last EndIf Link to comment Share on other sites More sharing options...
beardeus Posted September 26, 2015 Author Share Posted September 26, 2015 Taking a look now I3ill, thanks. Link to comment Share on other sites More sharing options...
beardeus Posted September 26, 2015 Author Share Posted September 26, 2015 132, 120, 90, 25) Hmmm...are these coordinates? I haven't been using them. I am a beginner so my installs mainly consist of ("{Tab}") or ("!a") to maneuver. I first started using sleeps but that wasn't making things go smoothly. I instead used WinWaitActive which has worked like a charm. I wasn't aware I could use that and then select text from within the install window. I first thought I had to select only text from the install title and the installer has the same title throughout. Now I just have a text box and need to input data there. My script of the installation looks VERY primitive compared to what you guys have.Thanks for all of the welcomes. I am remoting into my work computer to figure this out. It is fun/exciting for me to learn something new. Link to comment Share on other sites More sharing options...
ahmeddzcom Posted September 26, 2015 Share Posted September 26, 2015 (edited) maybe this will helpexpandcollapse popup#include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> Global $g_idMemo _Example_Defaults() Func _Example_Defaults() ; Create GUI $hGui = GUICreate("GetOpenFileName use defaults", 400, 296) $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") $id_Dialog = GUICtrlCreateButton("Open File", 155, 270, 90, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $id_Dialog $aFile = FileOpenDialog("", @DesktopDir & "\", "(*.ini)") $line = FileReadLine($aFile,2) ;~ Read Line 2 MemoWrite($line) Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGui) EndFunc ;==>_Example_Defaults ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite;~ Read Line 2 in File.ini Edited September 26, 2015 by ahmeddzcom beardeus 1 Link to comment Share on other sites More sharing options...
ahmeddzcom Posted September 26, 2015 Share Posted September 26, 2015 (edited) This reading All :expandcollapse popup#include <GUIConstantsEx.au3> #include <StructureConstants.au3> #include <WinAPI.au3> #include <WindowsConstants.au3> #include <File.au3> Global $g_idMemo _Example_Defaults() Func _Example_Defaults() ; Create GUI $hGui = GUICreate("GetOpenFileName use defaults", 400, 296) $g_idMemo = GUICtrlCreateEdit("", 2, 32, 396, 226, $WS_HSCROLL) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") $id_Dialog = GUICtrlCreateButton("Open File", 155, 270, 90, 20) GUISetState(@SW_SHOW) While 1 Switch GUIGetMsg() Case $id_Dialog $aFile = FileOpenDialog("", @DesktopDir & "\", "(*.ini)") $line = FileReadLine($aFile) For $i = 1 to _FileCountLines($aFile) $line = FileReadLine($aFile, $i) MemoWrite($line) Next Case $GUI_EVENT_CLOSE ExitLoop EndSwitch WEnd GUIDelete($hGui) EndFunc ;==>_Example_Defaults ; Write a line to the memo control Func MemoWrite($sMessage) GUICtrlSetData($g_idMemo, $sMessage & @CRLF, 1) EndFunc ;==>MemoWrite Edited September 26, 2015 by ahmeddzcom Link to comment Share on other sites More sharing options...
l3ill Posted September 27, 2015 Share Posted September 27, 2015 132, 120, 90, 25) Hmmm...are these coordinates? I haven't been using them. I am a beginner so my installs mainly consist of ("{Tab}") or ("!a") to maneuver. I first started using sleeps but that wasn't making things go smoothly. I instead used WinWaitActive which has worked like a charm. I wasn't aware I could use that and then select text from within the install window. I first thought I had to select only text from the install title and the installer has the same title throughout. Now I just have a text box and need to input data there. My script of the installation looks VERY primitive compared to what you guys have.Thanks for all of the welcomes. I am remoting into my work computer to figure this out. It is fun/exciting for me to learn something new.Yes, these are GUI coords aka. Function Parameters.Probably not necessary for your project, I was just working on this when I saw your question and thought it might help.If you are just trying to place text into edit boxes from an ini file then you will need JLogan3o13 's suggestionIniRead coupled with ControlSetTextGive it a shot and come back if you get stuck, don't forget to show your work (code) as it makes it easier to help & troubleshoot ;-)cya,Bill My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
l3ill Posted September 27, 2015 Share Posted September 27, 2015 Here a different snippet changed to a bit to reproduce the above mentioned:(the sleeps are only there so you can see it work)$sSelect = IniRead(@ScriptDir & "\login.ini", "login", "HostName", "Default Value") Run("rundll32.exe shell32.dll,#61") WinWaitActive("Run") Sleep(1000) ControlSetText("Run", "", "[CLASS:Edit; INSTANCE:1]", $sSelect) Sleep(1000) ControlClick("Run", "", "[CLASS:Button; INSTANCE:2]")[login] HostName=my ini text UserName= PassWord=save this as "login.ini" My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example Link to comment Share on other sites More sharing options...
beardeus Posted September 28, 2015 Author Share Posted September 28, 2015 I'm sorry. This is just all too confusing for me. I don't know enough of the variables used to be able to take an existing ini, read from it and then place the ini data to text boxes. Thanks for everyone's help. I just might have to scrap the whole ini part. Link to comment Share on other sites More sharing options...
JohnOne Posted September 28, 2015 Share Posted September 28, 2015 If you cannot copy and past from the above examples, then I think yes, you probably should. 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...
beardeus Posted September 28, 2015 Author Share Posted September 28, 2015 (edited) Hi JohnOne, I'm a total AutoIT noob that started using it on Thursday or Friday. This is what I have. Ignore the directory name. The text box is just returning the text "$Answer". I thought it would be returning the value of the .ini in the text box that is associated with $Answer.$Answer=IniRead("Directory","LocalDomain","Domain","FAILURE!")Winactivate ("Installer", "SQL")ControlSend("Installer","","","$Answer") Edited September 28, 2015 by beardeus Link to comment Share on other sites More sharing options...
beardeus Posted September 28, 2015 Author Share Posted September 28, 2015 Never mind. Figured it out! Link to comment Share on other sites More sharing options...
JohnOne Posted September 28, 2015 Share Posted September 28, 2015 I'm glad to hear that.It is customary to post your solution for other passers by to glean information from. 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...
beardeus Posted September 28, 2015 Author Share Posted September 28, 2015 (edited) Sure johnOne. Again, I am a total nub here so my code my seem very elementary.expandcollapse popup#include <WinAPIFiles.au3> Sleep(1000) ;Read from the ini file to populate text boxes $Answer=IniRead("C:\Users\TESTING\Desktop\Automated Install.ini","LocalDomain","Domain","FAILURE!") Sleep(1000) Winactivate ("Enterprise - InstallShield Wizard", "SQL") ControlSend("Enterprise - InstallShield Wizard","SQL","",$Answer) Send ("{Tab}") Send ("{Tab}") $Answer1=IniRead("C:\Users\TESTING\Desktop\Automated Install.ini","LocalDomain","DomainPassword","FAILURE!") ControlSend("Enterprise - InstallShield Wizard","SQL","",$Answer1) Send ("{Tab}") $Answer2=IniRead("C:\Users\TESTING\Desktop\Automated Install.ini","SQL","Server","FAILURE!") ControlSend("Ipro eCapture Enterprise - InstallShield Wizard","SQL","",$Answer2) Send ("{Tab}") Send ("{Tab}") $Answer3=IniRead("C:\Users\TESTING\Desktop\Automated Install.ini","SQL","Database","FAILURE!") ControlSend("Enterprise - InstallShield Wizard","SQL","",$Answer3) Send ("{Tab}") Send ("{Tab}") $Answer4=IniRead("C:\Users\TESTING\Desktop\Automated Install.ini","SQL","LoginID","FAILURE!") ControlSend("Enterprise - InstallShield Wizard","SQL","",$Answer4) Send ("{Tab}") $Answer5=IniRead("C:\Users\TESTING\Desktop\Automated Install.ini","SQL","Password","FAILURE!") ControlSend("Enterprise - InstallShield Wizard","SQL","",$Answer5) Sleep(200) ControlClick("Enterprise - InstallShield Wizard","","Validate") Send("{Enter}") WinWaitActive ("Enterprise - InstallShield Wizard", "Passed") Send("{Enter}") Sleep (2500) WinWaitActive ("Enterprise - InstallShield Wizard") Sleep(200) Send("!n") Sleep(200) Send("{Enter}") ;Sleep (450000) WinWaitActive ("Enterprise - InstallShield Wizard", "Completed") Sleep (1000) Send("{Enter}") Sleep (10000) Edited September 28, 2015 by beardeus Link to comment Share on other sites More sharing options...
JohnOne Posted September 28, 2015 Share Posted September 28, 2015 Couple of things. You should try to get the correct controlID you are sending to.That would eliminate all the TAB sending.If these controls have no ID's consider.Send("{TAB 2}") will send TAB twice. 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...
l3ill Posted September 28, 2015 Share Posted September 28, 2015 Another tip since you mentioned your trouble with variables here is a perfect chance to learn.Change your paths to variables and then you will only have to change one path instead of many.Example:#include <WinAPIFiles.au3> $installPath = "C:\Users\TESTING\Desktop\Automated Install.ini" ; in the future only need to change this ;Read from the ini file to populate text boxes $Answer=IniRead($installPath,"LocalDomain","Domain","FAILURE!") Sleep(1000) Winactivate ("Enterprise - InstallShield Wizard", "SQL") ControlSend("Enterprise - InstallShield Wizard","SQL","",$Answer) Send ("{Tab}") Send ("{Tab}") $Answer1=IniRead($installPath,"LocalDomain","DomainPassword","FAILURE!") ControlSend("Enterprise - InstallShield Wizard","SQL","",$Answer1) Send ("{Tab}") $Answer2=IniRead($installPath,"SQL","Server","FAILURE!") ControlSend("Ipro eCapture Enterprise - InstallShield Wizard","SQL","",$Answer2) ;;;===and so on... My Contributions... SnippetBrowser NewSciTE PathFinder Text File Manipulation FTP Connection Tester / INI File - Read, Write, Save & Load Example 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