I lost a full days work yesterday!
So here is my first public script to fix that!
Code:
/*
Notepad++ autosave and launch
If notepad++ is active, and you have not touched the keyboard or mouse for 5 sec, it saves all.
Then, it checks to see if there has been no activity for 15 min, if notepad++ is still runing, even if it is not active, it brings it to the front and saves.. (lunch time) :-)
*/
DetectHiddenText, On
SetTitleMatchMode, 2
SetBatchLines -1
#SingleInstance ignore
#WinActivateForce
#notrayicon
;if notepad++ is not running
process, exist, notepad++.exe
If ! errorLevel
{
run, %A_ProgramFiles%\Notepad++\Notepad++.exe
}
sleep, 60000
dome:
loop, 45 ;after 7.5 min,
{
sleep, 10000
if A_TimeIdlePhysical > 5000 ;after at least 5 sec of not doing anything and if notepad++ is currently active
{
If WinActive("ahk_class Notepad++")
{
blockinput, On
send, {Control Down}{Shift Down}s{Control Up}{Shift Up} ;save all
Blockinput, off
}
process, exist, notepad++.exe
If ! errorLevel
{
exitapp ;if not running, exit
}
}
}
if A_TimeIdlePhysical > 900000 ;if idle time more than 15 min, then force it to activate and then save.
{
winactivate ("ahk_class Notepad++")
sleep, 1000
blockinput, On
send, {Control Down}{Shift Down}s{Control Up}{Shift Up} ;save all
Blockinput, off
goto, dome
}
goto, dome
---edit added blockinput