forked from Drugoy/Autohotkey-scripts-.ahk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
GoneIn60s.ahk
356 lines (301 loc) · 7.37 KB
/
GoneIn60s.ahk
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
; http://www.donationcoder.com/Software/Skrommel/index.html#GoneIn60s
;GoneIn60s.ahk
; Recover closed applications
;Skrommel @ 2006
#NoEnv
#SingleInstance,Force
OnExit,EXIT
CoordMode,Mouse,Screen
CoordMode,ToolTip,Screen
SysGet,SM_CYCAPTION,4
SysGet,SM_CXBORDER,5
SysGet,SM_CYBORDER,6
SysGet,SM_CXEDGE,45
SysGet,SM_CYEDGE,46
SysGet,SM_CXFIXEDFRAME,7
SysGet,SM_CYFIXEDFRAME,8
SysGet,SM_CXSIZEFRAME,32
SysGet,SM_CYSIZEFRAME,33
SysGet,SM_CXSIZE,30
SysGet,SM_CYSIZE,31
applicationname=GoneIn60s
Gosub,INIREAD
inside=0
Gosub,TRAYMENU
SetTimer,CHECK,1000
Loop
{
Sleep,100
MouseGetPos,mx,my,win1
parent:=DllCall("GetParent","uint",win1)
If parent>0
Continue
WinGetPos,x,y,w,h,ahk_id %win1%
l:=x+w-SM_CXSIZEFRAME-SM_CXSIZE
t:=y+SM_CYSIZEFRAME
r:=x+w-SM_CXSIZEFRAME
b:=y+SM_CYSIZEFRAME+SM_CYSIZE
If (mx<l Or mx>r Or my<t Or my>b)
{
If inside=1
{
ToolTip,
Hotkey,LButton,CLICK,Off
inside=0
}
}
Else
{
If inside=0
{
WinGet,program,ProcessName,ahk_id %win1%
If program In %ignore%
Continue
WinGetClass,class,ahk_id %win1%
If class In %nonwindows%
Continue
ToolTip,Gone in %timeout% seconds
Hotkey,LButton,CLICK,On
inside=1
}
}
}
!F4::
WinGet,win1,Id,A
parent:=DllCall("GetParent",UInt,win1)
If parent>0
Return
WinGetClass,class,ahk_id %win1%
If class In %nonwindows%
Return
CLICK:
WinHide,ahk_id %win1%
IfNotInString,closing,%win1%
{
closing=%closing%%win1%-%A_TickCount%|
Gosub,TRAYMENU
}
Return
CHECK:
StringSplit,part_,closing,|
Loop,% part_0-1
{
StringSplit,info_,part_%A_Index%,-
IfWinExist,ahk_id %info_1%
{
left:=Ceil((info_2+timeout*1000-A_TickCount)/1000)
TrayTip,%applicationname%,Recovered with %left% seconds left!
StringReplace,closing,closing,%info_1%-%info_2%|
Gosub,TRAYMENU
}
Else
If (A_TickCount>=info_2+timeout*1000)
{
DetectHiddenWindows,On
If kill=1
{
WinGet,pid,Pid,ahk_id %info_1%
Process,Close,%pid%
}
Else
WinClose,ahk_id %info_1%
DetectHiddenWindows,Off
Sleep,1000
WinShow,ahk_id %info_1%
StringReplace,closing,closing,%info_1%-%info_2%|
Gosub,TRAYMENU
}
}
Return
RECOVER:
menuitem:=A_ThisMenuItemPos-4
StringSplit,part_,closing,|
StringSplit,info_,part_%menuitem%,-
WinShow,ahk_id %info_1%
Return
RECOVERALL:
StringSplit,part_,closing,|
Loop,% part_0-1
{
StringSplit,info_,part_%A_Index%,-
WinShow,ahk_id %info_1%
}
Return
CLOSEALL:
StringSplit,part_,closing,|
Loop,% part_0-1
{
StringSplit,info_,part_%A_Index%,-
DetectHiddenWindows,On
If kill=1
{
WinGet,pid,Pid,ahk_id %info_1%
Process,Close,%pid%
}
Else
WinClose,ahk_id %info_1%
DetectHiddenWindows,Off
Sleep,1000
WinShow,ahk_id %info_1%
StringReplace,closing,closing,%info_1%-%info_2%|
Gosub,TRAYMENU
}
Return
SETTINGS:
ok=0
Gui,Destroy
Gui,Margin,20,10
Gui,Add,GroupBox,xm-10 w300 h50,&Time to wait
Gui,Add,Edit,xm yp+20 w100 vtimeout
Gui,Add,UpDown,x+5,%timeout%
Gui,Add,Text,x+5 yp+2,seconds
Gui,Add,GroupBox,xm-10 y+20 w300 h50,Actions
Gui,Add,CheckBox,xm yp+20 vkill Checked%kill%,&Kill windows Won't ask to save changed documents!
Gui,Add,GroupBox,xm-10 y+20 w300 h120,&Programs to ignore
Gui,Add,Edit,xm yp+20 r5 w280 vignore,%ignore%
Gui,Add,Text,xm y+5,Example: Notepad.exe,Calc.exe,Pbrush.exe
Gui,Add,GroupBox,xm-10 y+20 w300 h120,Cl&asses to ignore
Gui,Add,Edit,xm yp+20 r5 w280 vsystem,%system%
Gui,Add,Text,xm y+5,Example: Shell_TrayWnd,Progman,#32768
Gui,Add,Button,xm y+20 w75 gSETTINGSOK,&OK
Gui,Add,Button,x+5 w75 gSETTINGSCANCEL,&Cancel
Gui,Show,,%applicationname% Settings
Loop
{
If ok=1
Break
MouseGetPos,x,y,winid,ctrlid
WinGet,program,ProcessName,ahk_id %winid%
WinGetClass,class,ahk_id %winid%
ToolTip,Program: %program%`nClass: %class%
Sleep,100
}
ToolTip,
Return
GuiClose:
SETTINGSOK:
ok=1
Gui,Submit
Gosub,INIWRITE
Return
SETTINGSCANCEL:
ok=1
Gui,Destroy
Return
TRAYMENU:
Menu,Tray,NoStandard
Menu,Tray,DeleteAll
Menu,Tray,Add,%applicationname%,RECOVERALL
Menu,Tray,Add
Menu,Tray,Add,&Recover All,RECOVERALL
Menu,Tray,Add
DetectHiddenWindows,On
StringSplit,part_,closing,|
Loop,% part_0-1
{
StringSplit,info_,part_%A_Index%,-
WinGetTitle,title,ahk_id %info_1%
Menu,Tray,Add,&%A_Index% - %title%,RECOVER
}
DetectHiddenWindows,Off
Menu,Tray,Add
Menu,Tray,Add,&Settings...,SETTINGS
Menu,Tray,Add,&About...,ABOUT
Menu,Tray,Add,E&xit,EXIT
Menu,Tray,Default,%applicationname%
Menu,Tray,Tip,%applicationname%
Return
ABOUT:
ok=1
Gui,99:Destroy
Gui,99:Margin,20,20
Gui,99:Add,Picture,xm Icon1,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,%applicationname% v1.4
Gui,99:Font
Gui,99:Add,Text,y+10,Recover closed applications
Gui,99:Add,Text,y+10,- To recover, rightclick the tray icon and choose an application
Gui,99:Add,Text,y+10,- Doubleclick the tray icon to recover all closed applications
Gui,99:Add,Text,y+10,- If not recovered, it is gone in %timeout% seconds
Gui,99:Add,Picture,xm y+20 Icon5,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,1 Hour Software by Skrommel
Gui,99:Font
Gui,99:Add,Text,y+10,For more tools, information and donations, please visit
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 G1HOURSOFTWARE,www.1HourSoftware.com
Gui,99:Font
Gui,99:Add,Picture,xm y+20 Icon7,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,DonationCoder
Gui,99:Font
Gui,99:Add,Text,y+10,Please support the contributors at
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GDONATIONCODER,www.DonationCoder.com
Gui,99:Font
Gui,99:Add,Picture,xm y+20 Icon6,%applicationname%.exe
Gui,99:Font,Bold
Gui,99:Add,Text,x+10 yp+10,AutoHotkey
Gui,99:Font
Gui,99:Add,Text,y+10,This tool was made using the powerful
Gui,99:Font,CBlue Underline
Gui,99:Add,Text,y+5 GAUTOHOTKEY,www.AutoHotkey.com
Gui,99:Font
Gui,99:Show,,%applicationname% About
hCurs:=DllCall("LoadCursor","UInt",NULL,"Int",32649,"UInt") ;IDC_HAND
OnMessage(0x200,"WM_MOUSEMOVE")
Return
1HOURSOFTWARE:
Run,http://www.1hoursoftware.com,,UseErrorLevel
Return
DONATIONCODER:
Run,http://www.donationcoder.com,,UseErrorLevel
Return
AUTOHOTKEY:
Run,http://www.autohotkey.com,,UseErrorLevel
Return
99GuiClose:
Gui,99:Destroy
OnMessage(0x200,"")
DllCall("DestroyCursor","Uint",hCur)
Return
WM_MOUSEMOVE(wParam,lParam)
{
Global hCurs
MouseGetPos,,,,ctrl
If ctrl in Static10,Static14,Static18
DllCall("SetCursor","UInt",hCurs)
Return
}
Return
EXIT:
Gosub,CLOSEALL
ExitApp
INIREAD:
IniRead,timeout,%applicationname%.ini,Settings,timeout
If timeout=ERROR
timeout=60
IniRead,kill,%applicationname%.ini,Settings,kill
If kill=ERROR
kill=0
IniRead,ignore,%applicationname%.ini,Settings,ignore
If ignore=ERROR
ignore=Notepad.exe
IniRead,system,%applicationname%.ini,Settings,system
If system=ERROR
system=Shell_TrayWnd,Progman,#32768,Basebar,DV2ControlHost
StringReplace,ignore,ignore,%A_Space%`,,`,,All
StringReplace,ignore,ignore,`,%A_Space%,`,,All
StringReplace,system,system,%A_Space%`,,`,,All
StringReplace,system,system,`,%A_Space%,`,,All
Return
INIWRITE:
StringReplace,ignore,ignore,%A_Space%`,,`,,All
StringReplace,ignore,ignore,`,%A_Space%,`,,All
StringReplace,system,system,%A_Space%`,,`,,All
StringReplace,system,system,`,%A_Space%,`,,All
IniWrite,%timeout%,%applicationname%.ini,Settings,timeout
IniWrite,%kill%,%applicationname%.ini,Settings,kill
IniWrite,%ignore%,%applicationname%.ini,Settings,ignore
IniWrite,%system%,%applicationname%.ini,Settings,system
Return