r2dak Posted November 25, 2012 Share Posted November 25, 2012 (edited) hi I'm new to autoit and can you tell me how to let a user write a message and then save it to a file this is what i've coded so far and its working fine but its not suitable for a longer message with multiple lines can you tell me how can i do that thank you #include <File.au3> $var = "msg.txt" $num = InputBox("email address", "please enter your email address", "r2dak@exmaple.com", "",270,130) $txt= InputBox("write your text ", "Write your Message", "your text here", "",270,130) _FileWriteToLine($var, 1, "name: " & $num , 1) ;_FileWriteToLine($var, 13, "Date:" & $dnt , 1) _FileWriteToLine($var, 2, "msg :" & $txt , 1) MsgBox(64, "Thank you","thanks we will respond soon") Edited November 25, 2012 by r2dak [center][font=comic sans ms,cursive]PEACE & LOVE[/font][/center] Link to comment Share on other sites More sharing options...
mihaibr Posted November 25, 2012 Share Posted November 25, 2012 (edited) Hi @r2dak, and welcome to AutoitScript forum Because you're new here you should read the forum rules.And here's an example for what you want:$GUI = GUICreate("Form1", 307, 439, 192, 114) $Label1 = GUICtrlCreateLabel("Message:", 8, 8, 50, 17) $TextEdit = GUICtrlCreateEdit("", 8, 32, 289, 369) $SaveButton = GUICtrlCreateButton("Save", 112, 408, 75, 25) GUISetState(@SW_SHOW) $file=FileOpen("msg.txt",2) While 1 $nMsg = GUIGetMsg() Switch $nMsg Case -3 ;$GUI_EVENT_CLOSE Exit Case $SaveButton $data=GUICtrlRead($TextEdit) FileWrite($file,$data) FileClose($file) MsgBox(64, "Thank you","thanks we will respond soon") Exit EndSwitch Sleep(10) WEndIf you have any ohter questions, we are waiting! Edited November 25, 2012 by mihaibr Link to comment Share on other sites More sharing options...
r2dak Posted November 25, 2012 Author Share Posted November 25, 2012 thank you very much mihaibr its working only one little request but only if you have time, can you explain this code a little please, i just started learning autoit few days ago and just trying to understand the it properly thank you [center][font=comic sans ms,cursive]PEACE & LOVE[/font][/center] Link to comment Share on other sites More sharing options...
mihaibr Posted November 25, 2012 Share Posted November 25, 2012 (edited) ok$GUI = GUICreate("Form1", 307, 439)Will create a window with the title Form1 that has 307pixels width and 439pixels height$Label1 = GUICtrlCreateLabel("Message:", 8, 8, 50, 17)Will create a static Label control ,with the text "Message:",with left coordonate 8 and the right coordonate 8,width 50 pixels and height 17$TextEdit = GUICtrlCreateEdit("", 8, 32, 289, 369)Will create an Edit control,with left 8px,top 32px,width 289px and height 369px$SaveButton = GUICtrlCreateButton("Save", 112, 408, 75, 25)Will create a button with the text "Save", left 112px,top 408px,width 75px and height 25pxGUISetState(@SW_SHOW)Will set the GUI state as "Show"$file=FileOpen("msg.txt",2)FileOpen opens a text file for reading or writing.While 1$nMsg = GUIGetMsg()Switch $nMsgCase -3 ;$GUI_EVENT_CLOSEExitCase $SaveButton$data=GUICtrlRead($TextEdit)FileWrite($file,$data)FileClose($file)MsgBox(64, "Thank you","thanks we will respond soon")ExitEndSwitchSleep(10)WEndThis is the main loop of the program$nMsg = GUIGetMsg()Polls the GUI to see if any events have occurred.Case -3 ;$GUI_EVENT_CLOSEExitCheck if the "x" (close) button is pressend and close the programCase $SaveButton$data=GUICtrlRead($TextEdit)FileWrite($file,$data)FileClose($file)MsgBox(64, "Thank you","thanks we will respond soon")ExitCheck if the "Save" button is pressed and then save the read the text from the Edit control($TextEdit) and save it into $dataThen using FileWrite he write the $data into the fileThen shows the MessageBox and exitHope you understant somethingSorry for my bad english.Here you can find all functions: http://www.autoitscript.com/autoit3/docs/functions.htmHere is the documentation: http://www.autoitscript.com/autoit3/docs/ Edited November 25, 2012 by mihaibr r2dak 1 Link to comment Share on other sites More sharing options...
r2dak Posted November 25, 2012 Author Share Posted November 25, 2012 Thank you very much now i got it don't worry about the English bro even my English is really bad muttley its not my first language i'm really thankful to for this you ROCK [center][font=comic sans ms,cursive]PEACE & LOVE[/font][/center] Link to comment Share on other sites More sharing options...
mihaibr Posted November 25, 2012 Share Posted November 25, 2012 (edited) Erm, I forgot, if you want to create GUIs/Forms easyer you can use Koda (press ALT+M in SciTE or Tools->Koda(Form Designer) ) If you got any other questions I wait them.(You can also PM me ) Edited November 25, 2012 by mihaibr Link to comment Share on other sites More sharing options...
r2dak Posted November 25, 2012 Author Share Posted November 25, 2012 wow that ALT+M wonderful thanks you very much i'll PM you if i need any Help [center][font=comic sans ms,cursive]PEACE & LOVE[/font][/center] 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