Jump to content

Create a .txt file with the current date / time?


 Share

Recommended Posts

Heres the code i got...

#include <File.au3>
#Include <Date.au3>
HotKeySet("^s", "Save")

Do
$text = ControlGetText("Map of Llirrem (English Province)     You're at RestartNearTown" , "" , "RichTextWndClass1")
$date = _NowDate()
$time = _NowTime()
sleep(100)
until 1 = 2

Func Save()
        If Not _FileCreate("QuestChatLog-" & $date & "-" & $time & ".txt") Then
            MsgBox(4096,"Error", " Error Creating Chat log file.      error:" & @error)
        EndIf
        $file = FileOpen("QuestChatLog-" & $date& "-" & $time & ".txt",1)

    
    If $file = -1 Then
        MsgBox(0, "Error", "Unable to open file.")
    EndIf
    
    FileWrite($file, $date & @CRLF & $text & @CRLF & @CRLF)
    FileClose($file)
            MsgBox(0,"Success!","Saved log")

EndFunc

thats what i got. I want to create a new file every time control S is pressed, and i want the name of the file to be QuestChatLog-Date-Time.txt, and contain the data it collects.

Why wont this work?

Edited by The_Noob
Link to comment
Share on other sites

I was informed that i didnt need a chunk of code that i removed because fileopen creates the file anyways, so i dont need _filecreate...

#include <File.au3>
#Include <Date.au3>
Opt("WinTitleMatchMode", 2)
HotKeySet("^s", "Save")
Global $text, $date, $time

Do
$text = ControlGetText("You're at RestartNearTown", "", "RichTextWndClass1")
$date = _NowDate()
$time = _NowTime()
Sleep(100)
Until 1 = 2

Func Save()
    $file = FileOpen("QuestChatLog-" & $date & "-" & $time & ".txt", 1)
    If @Error Then MsgBox(0, "Error", @Error)
    FileWrite($file, $date & @CRLF & $text & @CRLF & @CRLF)
    MsgBox(0,"Success!","Saved log")
    FileClose($file)
EndFunc

thats what i got now, and it still doesnt work... It doesnt come up with errors, but it doesnt save the file either. more ideas?

Edited by The_Noob
Link to comment
Share on other sites

HotKeySet("^s", "Save")

While 1
    Sleep(100)
WEnd

Func Save()
    $text = ControlGetText("Map of Llirrem (English Province)     You're at RestartNearTown" , "" , "RichTextWndClass1")
    $Date = @YEAR & "." & @MON & "." & @MDAY
    $Time = @HOUR & "." & @MIN & "." & @SEC
    $File = FileOpen("QuestChatLog-" & $Date & "-" & $Time & ".txt", 1)
    FileWrite($File, $text & @CRLF & $Date & @CRLF)
    MsgBox(0, "Success!", "Saved log")
    FileClose($File)
EndFunc

that ended up working... I think if theres too many lines in the chat it will not copy it over? weird.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...