Writing in a text file Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
ThomasPaine
Posts: 25
Joined: 24 Jun 2017, 22:17

Writing in a text file

18 Feb 2018, 22:23

Hello. I'm having problems writing in a text file:

ControlGetText, FoundText, WindowsForms10.Window.8.app.0.39490e2_r9_ad1112, Realm
FileAppend, %FoundText%, %A_ScriptDir%\test.txt


I know the first line works, so the problem must be with the fileappend line (nothing is written in the text file). If possible I would like to do something like this as well:

1) +%FoundText% - Time Stamp
2) +%FoundText% - Time Stamp
3) +%FoundText% - Time Stamp

Where every line written in the text file is a new iteration of a loop. Time Stamp would be the current time on the PC. So with every loop iteration, it writes the string stored in FoundText in a line in the text file along with the # of the loop and timestamp. Every iteration should have it's own line (same format as above). The most important thing for me however is to at least write the text down in the text file (each loop 1 line below the previous). I've looked at documentation and will continue to look in case there is no replies. Thanks a lot!
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Writing in a text file

18 Feb 2018, 23:05

What did you do to confirm that the first line works? Did you put a MsgBox, %FoundText% in between the first and last line to make sure the text was in the variable? If there is text in that variable, the second line will write it to the file.
User avatar
divanebaba
Posts: 805
Joined: 20 Dec 2016, 03:53
Location: Diaspora

Re: Writing in a text file

18 Feb 2018, 23:10

If your first line works and fills variable FoundText with content, than your issue is just how to get a new line. Writing into new line can be done as shown below:

Code: Select all

FileAppend, `n%FoundText%, %A_ScriptDir%\test.txt, UTF-8
`n creates a new line. UTF-8 format is recommended.
Einfach nur ein toller Typ. :mrgreen:
User avatar
boiler
Posts: 16925
Joined: 21 Dec 2014, 02:44

Re: Writing in a text file  Topic is solved

18 Feb 2018, 23:11

Here's how to get the time stamp in your loop:
FileAppend, +%FoundText% - %A_Now%`n, %A_ScriptDir%\test.txt

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: Google [Bot], Lamron750 and 241 guests