Tobytja Posted June 19, 2013 Share Posted June 19, 2013 Hello, when I want to put some variable to script, which's value is defined through GUICtrlCreateInput function, I can predefine the value by putting the appropriate text as the first function parameter. Can I somehow modify the parameter from the GUI? Like by creating a "save" button, which would rewrite the original function parameters inside of the script with the actual values in Input fields. Thanks Link to comment Share on other sites More sharing options...
water Posted June 19, 2013 Share Posted June 19, 2013 Do you mean GuiCtrlSetData to set the value of a Control? Or do you want to save the input to a file so that if you start the script again can retrieve the current value of the control from the file? My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Tobytja Posted June 19, 2013 Author Share Posted June 19, 2013 (edited) I mean, for example I have this command defined: GLOBAL $Input3 = GUICtrlCreateInput("Script", 134, 90, 209, 21) Which puts a word "Script" to the Input field, when the GUI is opened. After clicking on a button, script reads the value and starts. But if I modify the input value, the script doesn't remember it and next time the word "Script" appears there again. Say that someone else wants to have "DeuBa Script" as a preset value. Now he must open the script for editing and manually rewrite the parameter from "Script" to "DeuBa Script" or rewrite the value in the Input field each time he opens the GUI. I'd like to find a way to edit the command inside of the script, without having to open it for editing, so that it inside of the script looks like this: GLOBAL $Input3 = GUICtrlCreateInput("DeuBa Script", 134, 90, 209, 21) Is there any way to do this? Edited June 19, 2013 by Tobytja Link to comment Share on other sites More sharing options...
water Posted June 19, 2013 Share Posted June 19, 2013 (edited) Something like this? It reads the value for the input control from a ini file. As soon as you press "Save" the current value is saved to the input file and will be displayed as soon as you restart the script. #include <GUIConstantsEx.au3> Global $hSave, $msg Global $sInput = IniRead("Test.ini", "Config", "Input", "") GUICreate(" My GUI input", 320, 120, @DesktopWidth / 2 - 160, @DesktopHeight / 2 - 45) Global $hInput = GUICtrlCreateInput($sInput, 10, 5, 300, 20) $hSave = GUICtrlCreateButton("Save", 40, 75, 60, 20) GUISetState() $msg = 0 While $msg <> $GUI_EVENT_CLOSE $msg = GUIGetMsg() Select Case $msg = $hSave $sInput = GUICtrlRead($hInput) IniWrite("Test.ini", "Config", "Input", $sInput) EndSelect WEnd Edited June 19, 2013 by water My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
Tobytja Posted June 19, 2013 Author Share Posted June 19, 2013 Can it be done without any additional file? It would be more "idiot-proof", since most of the people using the script have no IT skill, they are just "trained monkeys". That's the reason I'm looking for a way to simplify the way to change preset values in the first place. So it could easily happen, that they forget they need this file, delete it and then come crying "hey, why it doesn't work?" Link to comment Share on other sites More sharing options...
TheSaint Posted June 19, 2013 Share Posted June 19, 2013 Well, another way is to write to and retrieve from the Registry. Obviously, if it finds no entry there, then it writes in the defaults ... which is what would happen if the program was run on another PC. An ini file is less intrusive though, and the program can also be set to recreate the ini with defaults if missing. Most users don't know about ini files and don't need to, as it should be an invisible interaction. To do as you request, would mean having to change the code of a compiled script, and then recompile it each time, which is even more of a hassle than worrying about ini files. At least with the registry option, the program can be relocated at will anywhere on the same PC, and have no problem recalling stored values. Make sure brain is in gear before opening mouth! Remember, what is not said, can be just as important as what is said. Spoiler What is the Secret Key? Life is like a Donut If I put effort into communication, I expect you to read properly & fully, or just not comment. Ignoring those who try to divert conversation with irrelevancies. If I'm intent on insulting you or being rude, I will be obvious, not ambiguous about it. I'm only big and bad, to those who have an over-active imagination. I may have the Artistic Liesense to disagree with you. TheSaint's Toolbox (be advised many downloads are not working due to ISP screwup with my storage) Link to comment Share on other sites More sharing options...
spudw2k Posted June 20, 2013 Share Posted June 20, 2013 I don't see anything wrong with using the registry to store the data in the user's hive. Spoiler Things I've Made: Always On Top Tool ◊ AU History ◊ Deck of Cards ◊ HideIt ◊ ICU ◊ Icon Freezer ◊ Ipod Ejector ◊ Junos Configuration Explorer ◊ Link Downloader ◊ MD5 Folder Enumerator ◊ PassGen ◊ Ping Tool ◊ Quick NIC ◊ Read OCR ◊ RemoteIT ◊ SchTasksGui ◊ SpyCam ◊ System Scan Report Tool ◊ System UpTime ◊ Transparency Machine ◊ VMWare ESX BuilderMisc Code Snippets: ADODB Example ◊ CheckHover ◊ Detect SafeMode ◊ DynEnumArray ◊ GetNetStatData ◊ HashArray ◊ IsBetweenDates ◊ Local Admins ◊ Make Choice ◊ Recursive File List ◊ Remove Sizebox Style ◊ Retrieve PNPDeviceID ◊ Retreive SysListView32 Contents ◊ Set IE Homepage ◊ Tickle Expired Password ◊ Transpose ArrayProjects: Drive Space Usage GUI ◊ LEDkIT ◊ Plasma_kIt ◊ Scan Engine Builder ◊ SpeeDBurner ◊ SubnetCalcCool Stuff: AutoItObject UDF ◊ Extract Icon From Proc ◊ GuiCtrlFontRotate ◊ Hex Edit Funcs ◊ Run binary ◊ Service_UDF 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