AutoHotkey – FileRead

FileRead reads the content of a text file to a variable.

Parameters

FileRead, Output, FileName

  • Output: variable that contains the file’s content.
  • FileName: the name of the file, if the file is not in %A_WorkingDir%, then specify the full file path.

Error handling

ErrorLevel is set to 0 if FileRead was successful.

Examples

Read a the file’s content into a variable.

; create a test file on desktop
FilePath := % A_Desktop "/" "test.txt"
FileAppend, % "Hello World!" "`n" "AutoHotkey rocks.", % FilePath
FileRead, File, % FilePath
MsgBox % File
FileDelete, % FilePath