#NoEnv SetWorkingDir %A_ScriptDir% #NoTrayIcon if !FileExist("C:\Documents and Settings\" A_UserName "\todo.txt") FileAppend, `n, C:\Documents and Settings\%A_UserName%\todo.txt Start: i := "" if FileExist("C:\Documents and Settings\" A_UserName "\todo_temp.txt") { Loop Read, C:\Documents and Settings\%A_UserName%\todo_temp.txt { i++ line%A_Index% := A_LoopReadLine } } else { Loop Read, C:\Documents and Settings\%A_UserName%\todo.txt { i++ line%A_Index% := A_LoopReadLine } } Gui, Add, Button, y4 x10 w75 h30 , OK Gui, Add, Button, y4 x95 w75 h30 , Cancel Loop %i% { y2 := 20 + A_Index * 20 Gui, Add, Edit, x5 y%y2% r1 w150 vtodo%A_Index% center, % line%A_Index% Gui, Add, Button, x157 y%y2% h20 w20 center gdel vdel%A_Index% -Tabstop , - } y2 += 25 Gui, Add, Button, x157 y%y2% h20 w20 center gadd, + Gui, +AlwaysOnTop -Caption +Border Gui, +LastFoundExist id := WinExist() ; Needed for #IfWinActive section GroupAdd todogui, ahk_id %id% ; Needed for #IfWinActive section if (line%i% = "") GuiControl Focus, Edit%i% ; Focus on last field after adding new line y2 := 918 - 20 * i Gui, Show, x874 y%y2% w180, todo-list Return #IfWinActive ahk_group todogui !^a:: PasteText("¹") ; Polish-specific character which caused some trouble when typed normally ^s:: #IfWinActive del: thisline := SubStr(A_GuiControl, 4) Gui Submit, NoHide ; FileCopy C:\Documents and Settings\%A_UserName%\todo.txt, C:\Documents and Settings\%A_UserName%\todo_back.txt, 1 FileDelete C:\Documents and Settings\%A_UserName%\todo_temp.txt Loop %i% { if (A_Index = thisline) Continue FileAppend % todo%A_Index% "`n", C:\Documents and Settings\%A_UserName%\todo_temp.txt } ; Reload Gui Destroy Goto Start Return add: Gui Submit, NoHide ; FileCopy C:\Documents and Settings\%A_UserName%\todo.txt, C:\Documents and Settings\%A_UserName%\todo_back.txt, 1 FileDelete C:\Documents and Settings\%A_UserName%\todo_temp.txt Loop %i% { FileAppend % todo%A_Index% "`n", C:\Documents and Settings\%A_UserName%\todo_temp.txt } FileAppend `n, C:\Documents and Settings\%A_UserName%\todo_temp.txt ; Reload Gui Destroy Goto Start Return ButtonOK: Gui Submit, NoHide FileCopy C:\Documents and Settings\%A_UserName%\todo.txt, C:\Documents and Settings\%A_UserName%\todo_back.txt, 1 FileDelete C:\Documents and Settings\%A_UserName%\todo.txt Loop %i% { FileAppend % todo%A_Index% "`n", C:\Documents and Settings\%A_UserName%\todo.txt } ButtonCancel: GuiEscape: GuiClose: FileDelete C:\Documents and Settings\%A_UserName%\todo_temp.txt ExitApp PasteText(text) { ClipBack := ClipboardAll Clipboard := "" sleep 10 Clipboard := text ClipWait 1 SendInput ^v sleep 10 Clipboard := ClipBack Return }