Henk Straten
Henk Straten

Reputation: 1447

Inserting the data in an autohotkey script

I have the following script that let's me insert a line in a text file:

^1::
     InputBox, text, fire writing, What did you achieve today?
     file := FileOpen("log.txt", "a")
     file.write(text "`n") 
     file.Close()
 return

I would now like to add a date to this so I get DDMMYYYY - mytext. Any thoughts on the edits I should make to this script so I can achieve this?

Upvotes: 2

Views: 157

Answers (1)

div
div

Reputation: 925

To format a date with AutoHotkey have a look at the documentation for FormatTime.

It takes the following arguments, where Format is the one you're looking to modify:

FormatTime, OutputVar , YYYYMMDDHH24MISS, Format

In your case your script would look somewhat like the following:

^1::
     FormatTime, TimeString,, ddMMyyyy
     InputBox, text, fire writing, What did you achieve today?
     file := FileOpen("log.txt", "a")
     file.write(TimeString . " - " . text "`n") 
     file.Close()
 return

Upvotes: 4

Related Questions