All of us were I work use the same spreadsheet to update maintenance assignments. If one person is using the sheet others cannot. Well, I would frequently leave my desk with that sheet open blocking others and would get many complaints
This I set out to fix with AHK. The idea is that if the sheet is open but inactive (out of focus) for some time OR if the computer is idle for some time, save and close the sheet.
It works most of the time but I find that it sometimes will be on my desktop, I'll check the Line Recently Executed page of AHK and find that it is not seeing the sheet open.
Below is the code in question.
Disclaimer: This is my first use of AHK. I really love it!!! Thank you.
Code:
BEGIN - Automatically shut the Maintainance forcast if not in use.
SetTimer, MaintForecast_AutoClose, 10000
Return
MaintForecast_AutoClose:
SetTitleMatchMode, 2
IfWinExist, Microsoft Excel - Mid Georgia Maintenance Schedule, ,[Read-Only],
{
IfWinActive
{
MFinactive := 0
}
IfWinNotActive
{
MFinactive++
}
NoOneAtMachine := A_TimeIdlePhysical
if(NoOneAtMachine > 600000 or MFinactive > 30)
{
WinActivate
Send ^s^w
Return
}
}
Return
;END - Automatically shut the Maintainance forcast if not in use.