Revision 346534376137 () - Diff

Link to this snippet: https://friendpaste.com/1hleOupaSVNrFQILQVbYUD
Embed:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
; Opera Shutdown 0.13
; Shutdowns/Hibernates computer when Opera completes transfers
; http://my.opera.com/Tamil/blog/show.dml/2094333

#NoTrayIcon
#SingleInstance Force
#NoEnv
SoundBeep

StringTrimRight, ScriptFullPathWithoutExt, A_ScriptFullPath, 4
PrefsFile = %ScriptFullPathWithoutExt%.ini
IfNotExist, %PrefsFile%
{
FileInstall, OperaShutdown.ini, %PrefsFile%, 1
FileSetTime, , %PrefsFile%, C
}

IniRead, TriggerText, %PrefsFile%, Prefs, Trigger Text
IniRead, CheckEvery, %PrefsFile%, Prefs, Check Every
IniRead, ConfirmationTimeout, %PrefsFile%, Prefs, Confirmation Timeout
IniRead, Hibernate, %PrefsFile%, Prefs, Hibernate
IniRead, Test, %PrefsFile%, Prefs, Test
IniRead, ExitShortcut, %PrefsFile%, Prefs, Exit Shortcut

If ExitShortcut
Hotkey, %ExitShortcut%, EXITPROGRAM

SetTitleMatchMode, 1
CheckEvery *= 60000
KillTimeout := ConfirmationTimeout*30000
ConfirmationTimeout *= 60
Goto, CHECKLOOP

CHECKLOOP:
Sleep, %CheckEvery%
IfWinExist, %TriggerText%
{
MsgBox, 36, , Opera transfers completed.`n`nDo you want to close Opera and shutdown/hibernate computer?, %ConfirmationTimeout%
IfMsgBox, No
ExitApp
If Test = 1
{
Gosub, CLOSEOPERA
MsgBox, 64, , The program is in test mode., %ConfirmationTimeout%
ExitApp
}
Else
{
If Hibernate = 1
DllCall("PowrProf\SetSuspendState", "int", 1, "int", 0, "int", 0)
Else
{
Gosub, CLOSEOPERA
Shutdown, 8
}
}
}
Else
Goto, CHECKLOOP

CLOSEOPERA:
WinClose, %TriggerText%
Sleep, %KillTimeout%
IfWinExist, %TriggerText%
WinKill, %TriggerText%
Return

EXITPROGRAM:
SoundBeep
ExitApp
Return