Jump to content

Save text inside of an input box


Jadog
 Share

Recommended Posts

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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

  • Moderators

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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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):

#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

  • Moderators

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:

#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

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png 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 columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...