#Requires AutoHotkey v2.0
filePath := "C:\file.txt" ; Path to the file where text will be saved
; Define the hotkey using Hotkey function (Win + X)
Hotkey("#x", ShowInputForm)
ShowInputForm(*) {
myGui := Gui("+AlwaysOnTop", "Text Appender")
myGui.SetFont("s10")
myGui.Add("Text", , "Enter text:")
inputBox := myGui.Add("Edit", "w300 r4") ; Multi-line Edit box
myGui.Add("Button", "w140 Default", "Save").OnEvent("Click", (*) => SaveText(inputBox, filePath, myGui))
myGui.Add("Button", "w140", "Cancel").OnEvent("Click", (*) => myGui.Destroy())
myGui.Show("AutoSize Center")
}
SaveText(inputBox, filePath, guiRef) {
inputText := Trim(inputBox.Value)
if (inputText = "") {
MsgBox("Please, add some text", "Empty Input", "Icon! T2")
return
}
FileAppend inputText "`r`n", filePath
guiRef.Destroy()
}