Code: Select all
#persistent
#singleinstance force
#NoEnv
IfExist, %A_MyDocuments%\auto shutdown -er settings.ini
{
Loop
{
FileReadLine, line%A_Index%, %A_MyDocuments%\auto shutdown -er settings.ini, %A_Index%
If ErrorLevel
break
}
}
Gui, New
Gui, Submit, NoHide
Gui, Add, Text,y1 Center cBlack vWinText , Welcome to ration's auto shutdown -er!
Gui, Add, Tab, w270 h200, General|Tips
Gui, Font, s14, Calibri
Gui, Add, Text, x12 y60, I shall check every
Gui, Add, Edit, x155 y59 w35 h27 number VSeconds ,%line1%
Gui, Font, S12
Gui, Add, DropDownList, x195 y57 w80 vTimeUnit , Minutes||Hours
Gui, Font, S14
Gui, Add, Text, x20 y95, and shut down
Gui, Add, Edit, x155 y95 w35 h27 number VSeconds2 ,%line2%
Gui, Font, S14
Gui, Add, Text, x194 y96, (min) after
Gui, Add, Button, default x17 y130 w255 h30, OK
Gui, Add, Text, x14 y165, Tip: Move the mouse to stop the`n shutdown after it triggers.
Gui Tab, Tip
Gui, Font, S12
Gui, Add, Text, x16 y40,This program will check for mouse `nmovements.`n If you don't move the mouse`nfor the amount of time you set in the `nfirst box, a shutdown schedule will start.`n You will have the "and shuts down ... `nafter" amount of minutes to move the`nmouse, which will make the the cycle `nreset and stop the shutdown.
Gui, Submit, NoHide
Gui, Show, w290 h230, Auto shutdown -er
Menu, Tray, add, Change_Settings
return
Change_Settings:
Run %A_ScriptFullPath%
Return
GuiSize:
GuiControl, MoveDraw, WinText, x0 w%A_GuiWidth%
Return
GuiClose:
Gui, Hide
ExitApp
ButtonOK:
Gui, Submit
IfExist, %A_MyDocuments%\auto shutdown -er settings.ini
{
FileDelete, %A_MyDocuments%\auto shutdown -er settings.ini
}
FileAppend,
(
%Seconds%
%seconds2%
), %A_MyDocuments%\auto shutdown -er settings.ini
If (TimeUnit = "Minutes")
{
waitA := Seconds * 1000 * 60
}
If (TimeUnit = "Hours")
{
waitA := Seconds * 1000 * 60 * 60
}
waitB := Seconds2 * 60
CoordMode, Mouse, Screen
Loop1:
Loop
{
AX:=""
AY:=""
BX:=""
BY:=""
MouseGetPos, AX, AY
Sleep, %waitA%
MouseGetPos, BX, BY
Sleep, 500
If ((AX=BX) and (AY=BY))
{
Run, Shutdown.exe -s -t %waitB%, %A_WinDir%\System32\
gosub, Loop2
}
}
Loop2:
Loop
{
AX:=""
AY:=""
BX:=""
BY:=""
MouseGetPos, AX, AY
Sleep, 500
MouseGetPos, BX, BY
Sleep, 100
If ((AX!=BX!) and (AY!=BY))
{
Run, Shutdown.exe -a, %A_WinDir%\System32\
gosub, Loop1
}
}
21.09 update : added change options in the tray icon options and fixed the second time var. (i forgot i used a defined var in the run first run command, changed it to user defined)