NELyon Posted June 21, 2006 Share Posted June 21, 2006 Heres what i am trying to say with that strange title. I need help with something. Is there any way to assign the text entered into an edit box to a variable? EXAMPLE: #include <GUIconstants.au3> GUIcreate("Whatev") GUICtrlCreateEdit("Type Text Here") Yeah i know that code is missing some args for GUICtrlCreateEdit but you get the idea. Is there any way to make "type your text here" or what the person typed in as $variable1? This is all for a small project i am working on...... when i finish it i will post it in scripts & scraps Link to comment Share on other sites More sharing options...
GaryFrost Posted June 21, 2006 Share Posted June 21, 2006 #include <GUIConstants.au3> GUICreate("My GUI edit") ; will create a dialog box that when displayed is centered $myedit=GUICtrlCreateEdit ("First line"& @CRLF, 176,32,121,97,$ES_AUTOVSCROLL+$WS_VSCROLL) GUISetState () ; will be append dont' forget 3rd parameter GUICtrlSetData ($myedit, "Second line",1) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend $s_data = GUICtrlRead($myedit) ; just to show you how to get the data MsgBox(0,"Data from Edit Box",$s_data) SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
NELyon Posted June 21, 2006 Author Share Posted June 21, 2006 (edited) AGH YES! thank you. Hmm... that first part is strait out of the beta help file... don't knw where the next parts are from EDIT: ok, so i got this. BUT, this won't work #include <GUIConstants.au3> HotKeySet("{enter}", "savefile") GUICreate("My GUI edit"); will create a dialog box that when displayed is centered $myedit=GUICtrlCreateEdit ("First line"& @CRLF, 176,32,121,97,$ES_AUTOVSCROLL+$WS_VSCROLL) GUISetState () ; will be append dont' forget 3rd parameter GUICtrlSetData ($myedit, "Second line",1) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() If $msg = $GUI_EVENT_CLOSE Then ExitLoop Wend Func Savefile() $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, $myedit) FileClose($file) EndFunc supposed to write the text from $myedit to test.txt. The filewrite function worked fine by itself (not with the variables, just plain text.) but this won't write Edited June 21, 2006 by codemyster Link to comment Share on other sites More sharing options...
GaryFrost Posted June 21, 2006 Share Posted June 21, 2006 expandcollapse popup#include <GUIConstants.au3> GUICreate("My GUI edit"); will create a dialog box that when displayed is centered $myedit = GUICtrlCreateEdit("First line" & @CRLF, 176, 32, 121, 97, $ES_AUTOVSCROLL + $WS_VSCROLL) $button = GUICtrlCreateButton("Save", 10, 300, 120, 25) GUISetState() ; will be append dont' forget 3rd parameter GUICtrlSetData($myedit, "Second line", 1) ; Run the GUI until the dialog is closed While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button _Savefile(GUICtrlRead($myedit)) EndSelect WEnd Func _Savefile($s_text) $file = FileOpen("test.txt", 1) ; Check if file opened for writing OK If $file = -1 Then MsgBox(0, "Error", "Unable to open file.") Exit EndIf FileWrite($file, $s_text) FileClose($file) EndFunc ;==>Savefile SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
NELyon Posted June 21, 2006 Author Share Posted June 21, 2006 (edited) Thank you very much. By the way, what i am trying to make is a code snippet holder... something i will need to use ALOT. it holds the data in snippets.txt EDIT: heres my first prototype/ leaves much to be desired. one thing i am trying to find out how to do is show the data of the text file in the GUI. You must first create a snippets.txt file in the scripts directory #include <GUIConstants.au3> GUICreate("My GUI edit", 350, 350) $myedit = GUICtrlCreateEdit("Welcome! Type your codes here!" & @CRLF, 30, 50, 300, 121, $ES_AUTOVSCROLL + $WS_VSCROLL) $button = GUICtrlCreateButton("Save", 175, 250, 120, 25) $button_2 = GUICtrlCreateButton ("Clear", 50, 250, 120, 25) GUISetState() While 1 $msg = GUIGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $button _Savefile(GUICtrlRead($myedit)) Case $msg = $button_2 GUICtrlSetData($myedit, "") EndSelect WEnd Func _Savefile($s_text) $file = FileOpen("Snippets.txt", 1) If $file = -1 Then MsgBox(0, "Error", "Unable to save file. Really sorry!") Exit EndIf FileWrite($file, $s_text) FileClose($file) EndFunc Where are those autoit codes when you need 'em? EDIT2: what the? it stoped working on me?!?! i added the clear button in Scite... could that have mesed it up? Edited June 21, 2006 by codemyster Link to comment Share on other sites More sharing options...
NELyon Posted June 21, 2006 Author Share Posted June 21, 2006 bump can anyone help? Link to comment Share on other sites More sharing options...
GaryFrost Posted June 21, 2006 Share Posted June 21, 2006 If your using the latest SciTe for Autoit, just Hit Alt+Ctl+S SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
NELyon Posted June 21, 2006 Author Share Posted June 21, 2006 Hmm... that brings up my computers properties... what's it supposed to do? Link to comment Share on other sites More sharing options...
GaryFrost Posted June 21, 2006 Share Posted June 21, 2006 Hmm... that brings up my computers properties... what's it supposed to do?shouldn't from with-in SciTE, also might try Tools/Snippet Holder from within SciTE SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
Rotahn Posted June 21, 2006 Share Posted June 21, 2006 when in the new version of Scite Press CTRL+ALT+S and it will bring up a Code Snippet Window for you Link to comment Share on other sites More sharing options...
NELyon Posted June 22, 2006 Author Share Posted June 22, 2006 (edited) Ok, i got everything working fine, almost. I started over and got this: #region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.6 Prototype #include <GuiConstants.au3> GuiCreate("Snippets Holder", 346, 373,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Edit_1 = GuiCtrlCreateEdit("Snippets", 30, 10, 280, 230) $Button_2 = GuiCtrlCreateButton("Clear", 20, 260, 130, 30) $Button_3 = GuiCtrlCreateButton("Save", 180, 260, 140, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 GUICtrlSetData($Edit_1, "") Case $msg = $Button_3 FileWrite("snippets.txt", $Edit_1) EndSelect WEnd Exit #endregion --- GuiBuilder generated code End --- This works except the filewrite part... all it writes is a "3" in the text file every time i click the save button. EDIT: i also tried INIWriting it but it still just wrote a "3" Edited June 22, 2006 by codemyster Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 22, 2006 Moderators Share Posted June 22, 2006 Ok, i got everything working fine, almost. I started over and got this: #region --- GuiBuilder code Start --- ; Script generated by AutoBuilder 0.6 Prototype #include <GuiConstants.au3> GuiCreate("Snippets Holder", 346, 373,-1, -1 , BitOR($WS_OVERLAPPEDWINDOW, $WS_CLIPSIBLINGS)) $Edit_1 = GuiCtrlCreateEdit("Snippets", 30, 10, 280, 230) $Button_2 = GuiCtrlCreateButton("Clear", 20, 260, 130, 30) $Button_3 = GuiCtrlCreateButton("Save", 180, 260, 140, 30) GuiSetState() While 1 $msg = GuiGetMsg() Select Case $msg = $GUI_EVENT_CLOSE ExitLoop Case $msg = $Button_2 GUICtrlSetData($Edit_1, "") Case $msg = $Button_3 FileWrite("snippets.txt", $Edit_1) EndSelect WEnd Exit #endregion --- GuiBuilder generated code End --- This works except the filewrite part... all it writes is a "3" in the text file every time i click the save button. EDIT: i also tried INIWriting it but it still just wrote a "3"It writes a 3 because that's the EditBox's Control ID, you didn't tell it to write anything else. Now if you replaced $Edit_1 with GUICtrlRead($Edit_1) now your telling it to write what is in the Edit box. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
NELyon Posted June 22, 2006 Author Share Posted June 22, 2006 Yes! Thanks smOke_n Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted June 22, 2006 Moderators Share Posted June 22, 2006 Yes! Thanks smOke_nNo problem, cameronsdad is always happy to help Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
NELyon Posted June 22, 2006 Author Share Posted June 22, 2006 rofl Off topic: I know a kid who always types that "roffles" Link to comment Share on other sites More sharing options...
GaryFrost Posted June 22, 2006 Share Posted June 22, 2006 As soon as Holger adds his fixes to the GUIRegisterMsg there will be a new version of Snippet Holder coming out. SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference. Link to comment Share on other sites More sharing options...
NELyon Posted June 22, 2006 Author Share Posted June 22, 2006 I decided to make something else instead of a snippet holder. Check out the link in my sig (SimpleEditor) 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