Misterium3 Posted March 2, 2010 Posted March 2, 2010 (edited) Hi all probably you will think that this is a stupid question and maybe it is XD but i need to do a Gui with a GuiCtrlCreateEdit that saves what i type in it in a txt file, and when i restart the program there must be written the content of the file... i wanted to use a button "Save" to save the text in the file... I tried but i failed because when i try to click on the button "Save" it saves "96" in the file and not what i type :/ Thank you ^^ and sorry for my bad english Edited March 2, 2010 by Misterium3
Fire Posted March 2, 2010 Posted March 2, 2010 (edited) #include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #Region ### START Koda GUI section ### Form=Form1.kxf $Form1 = GUICreate("TEST", 383, 364, 191, 127) $Edit1 = GUICtrlCreateEdit("TYPE HERE", 80, 48, 217, 209) $Button1 = GUICtrlCreateButton("save", 144, 296, 81, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $hsave=FileSaveDialog("Choose...",@ScriptDir,"Text Files (*.txt)") If $hsave="" Then cancel() else FileWrite($hsave&".txt",GUICtrlRead($Edit1)) MsgBox(64,"Saved","Document was saved",5) EndIf EndSwitch WEnd Func cancel() MsgBox(64,"Cancelled","Cancelled") EndFunc Edited March 2, 2010 by Sh3llC043r [size="5"] [/size]
Misterium3 Posted March 2, 2010 Author Posted March 2, 2010 LOL you're the best ^^ thanks very very very much ^^
Fire Posted March 2, 2010 Posted March 2, 2010 You can use this too: It does what you asking too: expandcollapse popup#include <ButtonConstants.au3> #include <EditConstants.au3> #include <GUIConstantsEx.au3> #include <WindowsConstants.au3> #include <File.au3> #include <Array.au3> Dim $avarray If FileExists(@TempDir&"\recent.ini") Then _FileReadToArray(@TempDir&"\recent.ini",$avarray) For $i=0 To $avarray[1] FileDelete(@TempDir&"\recent.ini") gui() Next EndIf $Form1 = GUICreate("TEST", 383, 364, 191, 127) $Edit1 = GUICtrlCreateEdit("", 80, 48, 217, 209) $Button1 = GUICtrlCreateButton("save", 144, 296, 81, 25, $WS_GROUP) GUISetState(@SW_SHOW) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $hsave=FileSaveDialog("save your file...",@ScriptDir,"Text Files (*.txt)") If $hsave="" Then cancel() else FileWrite($hsave&".txt",GUICtrlRead($Edit1)) MsgBox(64,"Saved","Document was saved",5) ;RunWait("cmd.exe /c " & "ECHO " & $hsave&".txt" & ">>" & @TempDir&"\recent.ini" & @CRLF,@ScriptDir,@SW_HIDE) ;FileWrite(@TempDir&"\recent.ini","") FileWrite(@TempDir&"\recent.ini",$hsave& ".txt") EndIf EndSwitch WEnd Func cancel() MsgBox(64,"Cancelled","Cancelled") EndFunc Func gui() $Form1 = GUICreate("TEST", 383, 364, 191, 127) $Edit1 = GUICtrlCreateEdit("", 80, 48, 217, 209) GUICtrlSetData($Edit1,FileRead($avarray[1])) $Button1 = GUICtrlCreateButton("save", 144, 296, 81, 25, $WS_GROUP) GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 $hsave=FileSaveDialog("Choose...",@ScriptDir,"Text Files (*.txt)") If $hsave="" Then cancel() else FileWrite($hsave&".txt",GUICtrlRead($Edit1)) MsgBox(64,"Saved","Document was saved",5) FileWrite(@TempDir&"\recent.ini",$hsave&".txt") EndIf EndSwitch WEnd EndFunc [size="5"] [/size]
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