Alright, So I am trying to make an autoit script to create a file and I just looked at the example on the function page for FileWriteLine everything seemed to make since so I added a GUISetOnEvent so that when the "done" button is pressed it will create a file with text in it and it will continue to write the text in it over and over again... I am just trying to get this to work before I do any other stuff. So I used Koda to make the gui real fast (that was the easy part) and I exported it etc and I added the GUISetOnEvent and the function from the FileWriteLine example and it doesn't work. I did get it to work once though but I had to generate the code from Koda with events on everybutton which then left minimize and close useless, so creating a file with text in it worked but closing the application itself didn't which was pretty useless. My question is "How do I make the FileWriteLine actually work?". With this code right now it will not create test.txt with "Line1 Line2 Line3" written in it. #include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#Region ### START Koda GUI section ### Form=C:UsersjustinDesktopcreat-vhostvhost-gui.kxf
$Form1 = GUICreate("Create a new vHost for localdev", 401, 201, 325, 193)
GUISetBkColor(0xFFFFFF)
$website = GUICtrlCreateInput("", 16, 40, 361, 21)
GUICtrlSetCursor (-1, 2)
$website_label = GUICtrlCreateLabel("Website Name ( Do not provide the extension ex. graphtek.com = graphtek )", 16, 16, 364, 17)
$done = GUICtrlCreateButton("Done", 304, 160, 73, 33)
GUICtrlSetOnEvent($done, "doneClick")
$coldfusion = GUICtrlCreateCheckbox("Is this a coldfusion site?", 16, 72, 281, 20)
$directory_edit = GUICtrlCreateButton("Edit Directories", 16, 160, 105, 33)
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
Func doneClick()
Local $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
FileWriteLine($file, "Line1")
FileWriteLine($file, "Line2" & @CRLF)
FileWriteLine($file, "Line3")
FileClose($file)
EndFunc