ATTENTION: You are viewing a page formatted for mobile devices; to view the full web page, click HERE.

DonationCoder.com Software > Post New Requests Here

AHK Script to create and delete a file until it is closed

<< < (2/2)

highend01:

--- ---#NoEnv
#SingleInstance force
SetWorkingDir %A_ScriptDir%
FileEncoding UTF-8
SetBatchLines, -1

drive := "C:\"
file  := "Dummy.txt"
path  := drive . file
text  := "Dummy"


if FileExist(drive) {
    Loop {
        EmptyFile(path)
        FileAppend, % text, % path
    }
}

EmptyFile(file) {
    hFile := DllCall("CreateFile", Str, file, UInt, 0x40000000, UInt, 3, UInt, 0, UInt, 5, UInt, 0, UInt, 0)
    DllCall("CloseHandle", UInt, hFile)
    return hFile > 0 ? 1 : hFile
}

But ofc this empties the file before it gets overwritten...

OpenFile() would impose too many problems (no unicode, no > 128 file path length...)

Navigation

[0] Message Index

[*] Previous page

Go to full version