Jadog Posted January 13, 2012 Share Posted January 13, 2012 I would like for my script to save (or remember) the text I type in the input box. It's rather cumbersome to type all this in each time I run it. I looked through several settings in Koda and couldn't find anything related. Is this possible? Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 13, 2012 Moderators Share Posted January 13, 2012 Jadog,You assign it to a variable like this:$sString = GUICtrlRead($hInput)If you want to store the value betwen runs then you need to save it to disk - the Ini* functions could be a useful tool for that. Koda does not help you here - this is not creating a GUI, this is real coding. Perhaps the excellent AutoIt tutorials that you will find here and here might be of use. M23 Emanoel 1 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...
Jadog Posted January 13, 2012 Author Share Posted January 13, 2012 Melba, thanks for the help. Ok, so I think I'm pretty close. I figured out how to write the ini file, but I can't figure out how to have the input box read it. I wasn't sure how to assign it to a variable like you suggested. Below is part of my script. $Input1 = GUICtrlCreateInput("MyServerTopLevelCompanyActivityImport", 143, 65, 361, 22) IniWrite("config.ini","Config","Input1",GUICtrlRead($Input1)) Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 13, 2012 Moderators Share Posted January 13, 2012 Jadog, When you want to read the value back from the ini file you do it like this: $Input1 = GUICtrlCreateInput(IniRead("config.ini", "Config", "Input1", ""), 143, 65, 361, 22) All clear? 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...
Jadog Posted January 13, 2012 Author Share Posted January 13, 2012 Thanks. It reads perfectly using your code: $Input1 = GUICtrlCreateInput(IniRead("config.ini", "Config", "Input1", ""), 143, 65, 361, 22) However, when I include the following, IniWrite("config.ini","Config","Input1",GUICtrlRead($Input1)) at the end of the script, then it won't write to the config.ini file. It will read from it, but it won't write anything to it. It just creates an ini file that looks like the following: [Config] Input1= Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 13, 2012 Moderators Share Posted January 13, 2012 Jadog, You mention that you are reading the input at the end of the script - are you sure that it still exists when you try to read it? If that is the case, what you can do is save the value as I showed above and then save that variable to the ini file later in the script: ; Read it $sInput1_Value = GUICtrlRead($Input1) ; Save it later IniWrite("config.ini", "Config", "Input1", $sInput1_Value) 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...
Jadog Posted January 13, 2012 Author Share Posted January 13, 2012 Ok, so I'm obviously not doing something correct because that didn't work for me either. Maybe it's the order of how I'm placing them, but I've tried it at the top and bottom in several different places and all give the same results. Here's my existing script (I've notated the two lines in question below): expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Marquee.au3> #include <excel.au3> ; ; ; ; #region ### START Koda GUI section ### Form=P:\TopLevel\AHOH\Activity\Import\SG2CP\SG2CP.kxf $Form1 = GUICreate("SG to CP Import Tool", 514, 427, 571, 195) $Group1 = GUICtrlCreateGroup("CP Information", 8, 8, 497, 201) $Input1 = GUICtrlCreateInput(IniRead("config.ini", "Config", "Input1", ""), 136, 36, 361, 21) ; <<<<<<<<<<<<<<<<<<<<<<<<<< Read from ini file GUICtrlSetTip(-1, "Select your import directory (Ex: \\MyServer\TopLevel\Company\Activity\Import") $Button1 = GUICtrlCreateButton("Import", 368, 344, 121, 41) $Button2 = GUICtrlCreateButton("Cancel", 228, 344, 121, 41) GUISetState(@SW_SHOW) #endregion ### END Koda GUI section ### IniWrite("config.ini","Config","Input1",GUICtrlRead($Input1)) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Write to ini file While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $oExcel = _ExcelBookOpen(GUICtrlRead($Input1) & "SG Update Vendor Items & Add New Products.xls", 1) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist!") Exit EndIf $oExcel.Run("AllOthers") Sleep(1000);1 seconds _ExcelBookSaveAs($oExcel, GUICtrlRead($Input1) & "SG Update Vendor Items & Add New Products.csv", "csv", 0, 1) _ExcelBookClose($oExcel, 0, 0) Sleep(1000);1 seconds Case $Button2 Exit EndSwitch WEnd Link to comment Share on other sites More sharing options...
Moderators Melba23 Posted January 14, 2012 Moderators Share Posted January 14, 2012 Jadog, I moved the above post from your other thread. At the moment you are saving the input content as soon as you have written it - so of course it will not have changed. You need to save it on exit so that the value of the input at that point is saved and can be reloaded on the next start: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <StaticConstants.au3> #include <WindowsConstants.au3> #include <Marquee.au3> #include <excel.au3> $Form1 = GUICreate("SG to CP Import Tool", 514, 427, 571, 195) $Group1 = GUICtrlCreateGroup("CP Information", 8, 8, 497, 201) $Input1 = GUICtrlCreateInput(IniRead("config.ini", "Config", "Input1", ""), 136, 36, 361, 21) ; <<<<<<<<<<<<<<<<<<<<<<<<<< Read from ini file GUICtrlSetTip(-1, "Select your import directory (Ex: MyServerTopLevelCompanyActivityImport") $Button1 = GUICtrlCreateButton("Import", 368, 344, 121, 41) $Button2 = GUICtrlCreateButton("Cancel", 228, 344, 121, 41) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE IniWrite("config.ini","Config","Input1",GUICtrlRead($Input1)) ;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<Write to ini file Exit Case $Button1 $oExcel = _ExcelBookOpen(GUICtrlRead($Input1) & "SG Update Vendor Items & Add New Products.xls", 1) If @error = 1 Then MsgBox(0, "Error!", "Unable to Create the Excel Object") Exit ElseIf @error = 2 Then MsgBox(0, "Error!", "File does not exist!") Exit EndIf $oExcel.Run("AllOthers") Sleep(1000);1 seconds _ExcelBookSaveAs($oExcel, GUICtrlRead($Input1) & "SG Update Vendor Items & Add New Products.csv", "csv", 0, 1) _ExcelBookClose($oExcel, 0, 0) Sleep(1000);1 seconds Case $Button2 Exit EndSwitch WEnd All clear? 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...
Jadog Posted January 16, 2012 Author Share Posted January 16, 2012 You make it look so simple . Thanks! 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