Sign in to follow this  
Followers 0
The_Noob

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

5 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites



Have a look at Dim, Local & Global

Global $date, $time

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

You are not allowed to create files that include ":"... Just try that in windows-explorer and you get a nice hint. :whistle:

Share this post


Link to post
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.

Share this post


Link to post
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
Sign in to follow this  
Followers 0