xtreempje Posted March 17, 2023 Share Posted March 17, 2023 (edited) Hey im currently trying to save an edit line as a variable but I can't get it to work #Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Test", 730, 670, 557, 189) $Edit1 = GUICtrlCreateEdit("", 8, 8, 705, 513) GUICtrlSetData(-1, "This is a test line") $Button1 = GUICtrlCreateButton("Test", 264, 568, 81, 25) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### global $line1 = _GUICtrlEdit_GetLine($Edit1, 0)) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 MsgBox($MB_SYSTEMMODAL, "Information", $line1) EndSwitch WEnd EndFunc Hope someone can help me with this or point me in a direction. Edited March 17, 2023 by xtreempje Link to comment Share on other sites More sharing options...
ioa747 Posted March 17, 2023 Share Posted March 17, 2023 $Edit1 is the id the identifier control. you must use GUICtrlRead ( controlID [, advanced = 0] ) I know that I know nothing Link to comment Share on other sites More sharing options...
xtreempje Posted March 17, 2023 Author Share Posted March 17, 2023 When I use GUICtrlRead I don't get anything popped up in my msgbox. but when I do MsgBox($MB_SYSTEMMODAL, "Information", _GUICtrlEdit_GetLine($Edit1, 0))) It does work and gives me the line in the msgbox but I want it to be saved as a variable so I can just use MsgBox($MB_SYSTEMMODAL, "Information", $line1) Link to comment Share on other sites More sharing options...
ioa747 Posted March 17, 2023 Share Posted March 17, 2023 #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 -w 5 -w 6 -w 7 #include <GUIConstantsEx.au3> #include <MsgBoxConstants.au3> #include <GuiEdit.au3> #Region ### START Koda GUI section ### Form= Global $Form2 = GUICreate("Test", 730, 670, 557, 189) Global $Edit1 = GUICtrlCreateEdit("", 8, 8, 705, 513) Global $Button1 = GUICtrlCreateButton("ok", 10, 600, 30, 25) Global $MyData = "This is a test line1" & @CRLF & "This is a test line2" GUICtrlSetData($Edit1, $MyData) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Button1 MsgBox($MB_SYSTEMMODAL, "Information", $MyData) EndSwitch WEnd global $line1 = _GUICtrlEdit_GetLine($Edit1, 0) MsgBox($MB_SYSTEMMODAL, "Information", $line1) I know that I know nothing Link to comment Share on other sites More sharing options...
ioa747 Posted March 17, 2023 Share Posted March 17, 2023 (edited) put on top of your script #AutoIt3Wrapper_Au3Check_Parameters=-d -w 1 -w 2 -w 3 -w 4 ;-w 5 -w 6 -w 7 at least until comment ; he will point out mistakes like this MsgBox($MB_SYSTEMMODAL, "Information", _GUICtrlEdit_GetLine($Edit1, 0))) or this global $line1 = _GUICtrlEdit_GetLine($Edit1, 0)) Edited March 17, 2023 by ioa747 SOLVE-SMART 1 I know that I know nothing Link to comment Share on other sites More sharing options...
xtreempje Posted March 17, 2023 Author Share Posted March 17, 2023 alright thanks alot! Link to comment Share on other sites More sharing options...
xtreempje Posted March 17, 2023 Author Share Posted March 17, 2023 Hey I have another question. I made it so it saves the text in a ini file and loads the text from the ini file but it only loads 1 line of text from the ini file even if i write down 500 lines and press save. the ini file does contain all my text but it only loads 1 line. This is how I load from the ini file : GUICtrlSetData($Edit1, IniRead("Config.ini", "Config", "Edit", "Example")) This is how i save to the ini file : IniWrite(@ScriptDir & "/Config.ini","Config","Edit",GUICtrlRead($Edit1)) and this is the ini file : [Config] Edit=This is a test a test to check if it loads more lines than 1 but it does not This is the full script for now to try get it to work Region ### START Koda GUI section ### Form= $Form2 = GUICreate("Form2", 730, 670, 557, 189) $Edit1 = GUICtrlCreateEdit("", 8, 8, 705, 513) GUICtrlSetData(30, "Example") $Save = GUICtrlCreateButton("Save", 24, 616, 193, 33) $Close = GUICtrlCreateButton("Close", 235, 616, 137, 33) GUICtrlSetData($Edit1, IniRead("Config.ini", "Config", "Edit", "Example")) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### _main() Func _main() GUISetState(@SW_SHOWNORMAL) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Save IniWrite(@ScriptDir & "/Config.ini","Config","Edit",GUICtrlRead($Edit1)) Save() EndSwitch WEnd EndFunc Link to comment Share on other sites More sharing options...
ioa747 Posted March 17, 2023 Share Posted March 17, 2023 from AutoIt Help A standard ini file looks like: [SectionName] Key=Value I know that I know nothing Link to comment Share on other sites More sharing options...
Dan_555 Posted March 18, 2023 Share Posted March 18, 2023 (edited) What you can do is either to save the lines from the edit box in each key value e.g. Quote 1=Line 1 2=Line 2 or to replace the return chars (@crlf) from the edit box with some custom word, which will usually not be used in the text, like @R@ in this example: #include <GUIConstants.au3> $Form2 = GUICreate("Form2", 730, 670, 557, 189) $Edit1 = GUICtrlCreateEdit("", 8, 8, 705, 513) GUICtrlSetData(30, "Example") $Save = GUICtrlCreateButton("Save", 24, 616, 193, 33) $Load = GUICtrlCreateButton("Load", 335, 616, 137, 33) GUICtrlSetData($Edit1, StringReplace(IniRead(@ScriptDir & "\Config.ini", "Config", "Edit", "Example"), "@R@", @CRLF)) GUISetState(@SW_SHOW) _main() Func _main() GUISetState(@SW_SHOWNORMAL) While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE ExitLoop Case $Load GUICtrlSetData($Edit1, StringReplace(IniRead(@ScriptDir &"\Config.ini", "Config", "Edit", "Example"), "@R@", @CRLF)) Case $Save IniWrite(@ScriptDir & "\Config.ini", "Config", "Edit", StringReplace(GUICtrlRead($Edit1), @CRLF, "@R@")) EndSwitch WEnd EndFunc ;==>_main Edited March 18, 2023 by Dan_555 Some of my script sourcecode 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