-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathAviSynth.ahk
467 lines (388 loc) · 14.8 KB
/
AviSynth.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
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
; requires TheArkyTekt_CommandLine.ahk
Global AviSynthHwnd
Global AviSynthX86, AviSynthX64
Global AviSynthRootPath, AviSynthSettings
Global AviSynthSel, AviSynthList, AviSynthLocalInstall, AviSynthNativeInstall, AviSynthRegistry, AviSynthRegistryList
Global AviSynthInstallBtn, AviSynthUninstallX86Btn, AviSynthUninstallX64Btn
AviSynthSettings := SettingLoad("AviSynth.txt")
AviSynthRootPath := SettingRead(AviSynthSettings,"AviSynthRootPath","=")
AviSynthX86 := SettingRead(AviSynthSettings,"AviSynthX86","=")
AviSynthX64 := SettingRead(AviSynthSettings,"AviSynthX64","=")
AviSynthRegistry := SettingRead(AviSynthSettings,"AviSynthRegistry","=")
If (AviSynthRegistry = "") {
AviSynthRegistry := "HKLM"
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthRegistry",AviSynthRegistry,"=")
}
If (AviSynthRegistry = "HKLM")
AviSynthRegistryList := "HKLM||HKCU"
Else
AviSynthRegistryList := "HKLM|HKCU||"
AviSynthLocalInstall := SettingRead(AviSynthSettings,"AviSynthLocalInstall","=")
If (AviSynthLocalInstall = "") {
AviSynthLocalInstall := 0
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthLocalInstall",AviSynthLocalInstall,"=")
}
AviSynthNativeInstall := SettingRead(AviSynthSettings,"AviSynthNativeInstall","=")
If (AviSynthNativeInstall = "") {
AviSynthNativeInstall := 0
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthNativeInstall",AviSynthNativeInstall,"=")
}
AviSynthGUI() {
If (AviSynthRootPath = "") {
isAvs := False
Loop, Files, %A_ScriptDir%\*, D
{
If (InStr(A_LoopFileName,"AviSynth")) {
isAvs := True, AviSynthRootPath := A_ScriptDir
Break
}
}
If (AviSynthRootPath = "") {
FileSelectFolder, RootPath, , , Select AviSynth Root Folder:
If (RootPath = "")
ExitApp
Else
AviSynthRootPath := RootPath
}
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthRootPath",AviSynthRootPath,"=")
}
Gui, AviSynthGui:New, +HwndAviSynthHwnd +LabelAviSynthGui +OwnDialogs, AviSynth Installer
Gui, Add, Text, Section, Root Path:
Gui, Add, Edit, x+2 yp-3 w328 vAviSynthRootPath, %AviSynthRootPath%
Gui, Add, Button, x+0 gAviSynthRootPathSel, Browse...
Gui, Add, Checkbox, xs y+3 vAviSynthLocalInstall gAviSynthLocalInstall, Attempt local install
Gui, Add, Checkbox, x+10 vAviSynthNativeInstall gAviSynthNativeInstall, Force native install
Gui, Add, Text, x+10, Registry:
Gui, Add, DropDownList, x+3 yp-3 w60 vAviSynthRegistry gAviSynthRegistry, %AviSynthRegistryList%
Gui, Add, Button, x+9 gTestInstall, Test Install
GUi, Add, Button, x+0 gHelpBtn, ?
GuiControl, , AviSynthLocalInstall, %AviSynthLocalInstall%
GuiControl, , AviSynthNativeInstall, %AviSynthNativeInstall%
Gui, Add, ListBox, xs w200 r5 vAviSynthSel gAviSynthSel
Gui, Add, Text, x+5 yp+3 w30 Right Section, x86:
Gui, Add, Edit, x+2 yp-3 w200 vAviSynthX86 ReadOnly, %AviSynthX86%
Gui, Add, Text, xs y+3 w30 Right, x64:
Gui, Add, Edit, x+2 yp-3 w200 vAviSynthX64 ReadOnly, %AviSynthX64%
Gui, Add, Button, xp y+0 vAviSynthInstallBtn gAviSynthInstallBtn Disabled, Install
Gui, Add, Button, x+0 vAviSynthUninstallX86Btn gAviSynthUninstallX86Btn, Uninstall x86
Gui, Add, BUtton, x+0 vAviSynthUninstallX64Btn gAviSynthUninstallX64Btn, Uninstall x64
AviSynthMakeList()
Gui, Show
}
AviSynthGuiClose(hwnd) {
If (hwnd = AviSynthHwnd) {
AviSynthSetW()
ExitApp
}
}
HelpBtn() {
msg := "-= Attempt local install =-`r`n`r`n"
. " This will refrain from copying over the DLL files to the system folder. "
. "The corresponding registry entries will write a full path to the DLL in the CLSID entry. "
. "Normally the CLSID registry entry is simply " Chr(34) "AviSynth.dll" Chr(34) "`r`n`r`n"
. "-= Force native install =-`r`n`r`n"
. " This will force installing a 32-bit AviSynth to the 64-bit location (applies to registry and system folders). "
. "I've only seen this used in conjunction with a " Chr(34) "local" Chr(34) " install.`r`n`r`n"
. "======================================`r`n"
. " I've added the options so people can try different configurations. Generally speaking, these options "
. "will work best when only installing a single version of AviSynth. If you want to use x86 and x64 side-by-side, "
. "then use the default install method.`r`n"
. "======================================`r`n`r`n"
. "-= Registry Selection =-`r`n`r`n"
. " Specify wich registry key to install to, HKLM or HKCU. This also applies when uninstalling, meaning that "
. "this program will only look in the specified location for the installed registry entries.`r`n`r`n"
. "======================================`r`n`r`n"
. "Reset to default options:`r`n"
. " uncheck both checkboxes`r`n"
. " Registry: HKLM`r`n`r`n"
. "The default installation will copy AviSynth DLLs to the system folders and install all registry entries. "
. "The default install method will work for all applications. "
. "If you use the options to change the defaults, unexpected things can happen. Use these options at your own risk."
MsgBox, , AviSynth Installer Help, %msg%
}
TestInstall() {
str := StdoutToVar("AvsVersion32.exe")
str .= "`r`n`r`n" StdoutToVar("AvsVersion64.exe")
msgbox % str
}
AvsVersion32() {
str := StdoutToVar("AvsVersion32.exe")
return str
}
AvsVersion64() {
str := StdoutToVar("AvsVersion64.exe")
return str
}
AviSynthSetW() {
SettingWrite("AviSynth.txt",AviSynthSettings)
}
AviSynthRootPathSel() {
FileSelectFolder, RootPath, *%AviSynthRootPath%, , Select AviSynth Root Folder:
If (RootPath) {
AviSynthRootPath := RootPath
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthRootPath",AviSynthRootPath,"=")
GuiControl, , AviSynthRootPath, %AviSynthRootPath%
}
}
AviSynthLocalInstall() {
GuiControlGet, AviSynthLocalInstall
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthLocalInstall",AviSynthLocalInstall,"=")
}
AviSynthNativeInstall() {
GuiControlGet, AviSynthNativeInstall
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthNativeInstall",AviSynthNativeInstall,"=")
}
AviSynthMakeList() {
Loop, Files, %AviSynthRootPath%\*, D
If (InStr(A_LoopFileName,"AviSynth") = 1 Or InStr(A_LoopFileName,"AVS") = 1)
AviSynthList .= A_LoopFileName "|"
AviSynthList := Trim(AviSynthList,OmitChars:="|")
GuiControl, , AviSynthSel, |%AviSynthList%
}
AviSynthRegistry() {
GuiControlGet, AviSynthRegistry
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthRegistry",AviSynthRegistry,"=")
}
AviSynthSel() {
GuiControl, Enable, AviSynthInstallBtn
}
; ========================================================
; Install / Uninstall button events
; ========================================================
AviSynthInstallBtn() {
GuiControlGet, AviSynthSel
dllPath := AviSynthRootPath "\" AviSynthSel
result := AviSynthInstall(dllPath,AviSynthRegistry,AviSynthLocalInstall,AviSynthNativeInstall)
If (InStr(dllPath,"x86") Or
. InStr(dllPath,"win32") Or
. InStr(dllPath,"win 32") Or
. InStr(dllPath,"win_32") Or
. InStr(dllPath,"x32") Or
. InStr(dllPath,"32-bit") Or
. InStr(dllPath,"32 bit") Or
. InStr(dllPath,"32bit")
. )
AvsArch := "x86"
Else If (InStr(dllPath,"x64") Or
. InStr(dllPath,"win64") Or
. InStr(dllPath,"win 64") Or
. InStr(dllPath,"win_64") Or
. InStr(dllPath,"64-bit") Or
. InStr(dllPath,"64 bit") Or
. InStr(dllPath,"64bit")
. )
AvsArch := "x64"
If (AvsArch = "x86") {
AviSynthX86 := AviSynthSel
GuiControl, , AviSynthX86, %AviSynthX86%
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthX86",AviSynthX86,"=")
} Else {
AviSynthX64 := AviSynthSel
GuiControl, , AviSynthX64, %AviSynthX64%
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthX64",AviSynthX64,"=")
}
}
AviSynthUninstallX86Btn() {
If (AviSynthX86) {
dllPath := AviSynthRootPath "\" AviSynthX86
result := AviSynthUninstall(dllPath,AviSynthRegistry)
GuiControl, , AviSynthX86
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthX86","","=")
}
}
AviSynthUninstallX64Btn() {
If (AviSynthX64) {
dllPath := AviSynthRootPath "\" AviSynthX64
result := AviSynthUninstall(dllPath,AviSynthRegistry)
GuiControl, , AviSynthX64
AviSynthSettings := SettingUpdate(AviSynthSettings,"AviSynthX64","","=")
}
}
; ========================================================
; Support Function
; ========================================================
AviSynthInstall(dllPath,node:="HKLM",tryLocal:=0,forceNative:=0) {
plus := 0, p := "", oops := 0
ServerPath := ""
If (tryLocal)
ServerPath := dllPath "\AviSynth.dll"
Else
ServerPath := "AviSynth.dll"
If (InStr(dllPath,"x86") Or
. InStr(dllPath,"win32") Or
. InStr(dllPath,"win 32") Or
. InStr(dllPath,"win_32") Or
. InStr(dllPath,"x32") Or
. InStr(dllPath,"32-bit") Or
. InStr(dllPath,"32 bit") Or
. InStr(dllPath,"32bit")
. )
AvsArch := "x86"
Else If (InStr(dllPath,"x64") Or
. InStr(dllPath,"win64") Or
. InStr(dllPath,"win 64") Or
. InStr(dllPath,"win_64") Or
. InStr(dllPath,"64-bit") Or
. InStr(dllPath,"64 bit") Or
. InStr(dllPath,"64bit")
. )
AvsArch := "x64"
If (A_Is64bitOS And forceNative = 0) {
If (AvsArch = "x64") {
installDir := A_WinDir "\System32"
regPath := ""
} Else {
installDir := A_WinDir "\SysWOW64"
regPath := "Wow6432Node\"
}
} Else {
installDir := A_WinDir "\System32"
regPath := ""
}
pluginDir := dllPath "\plugins" ; do it like the Universal Installer for AviSynth
if (node = "HKCU") ; force not using Wow6432Node if node="HKCU"
regPath := ""
; === check for AviSynth+ (Plus) ====================
If (InStr(dllPath,"+") Or InStr(dllPath,"plus"))
plus := 1, p := "+"
If (plus)
iconPath := dllPath "\AviSynth.dll,1"
Else
iconPath := dllPath "\AviSynth.dll,0"
staticIconPath := dllPath "\AviSynth.dll,0"
; === Copy DLLs to system folders =============
If (tryLocal = 0) {
FileCopy, %dllPath%\AviSynth.dll, %installDir%\AviSynth.dll, 1
If (ErrorLevel)
oops += ErrorLevel
FileCopy, %dllPath%\DevIL.dll, %installDir%\DevIL.dll, 1
If (ErrorLevel)
oops += ErrorLevel
If (oops) {
MsgBox Unable to copy all files to system folder(s).
return
}
}
; === Plugin Reg Entries ==================
RegWrite, REG_SZ, %node%\Software\%regPath%AviSynth, , %dllPath%
If (plus)
RegWrite, REG_SZ, %node%\Software\%regPath%AviSynth, PluginDir+, %pluginDir%
Else
RegWrite, REG_SZ, %node%\Software\%regPath%AviSynth, PluginDir2_5, %pluginDir%
; === 32/64 bit dll registration entries ===============
RegWrite, REG_SZ, %node%\Software\%regPath%Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}, , AviSynth%p%
RegWrite, REG_SZ, %node%\Software\%regPath%Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32, , %ServerPath%
RegWrite, REG_SZ, %node%\Software\%regPath%Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcServer32, ThreadingModel, Apartment
; RegWrite, REG_SZ, %node%\Software\%regPath%\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcHandler32, , %ServerPath%
; RegWrite, REG_SZ, %node%\Software\%regPath%\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}\InProcHandler32, ThreadingModel, Apartment
RegWrite, REG_SZ, %node%\Software\%regPath%Classes\Media Type\Extensions\.avs, Source Filter, {D3588AB0-0781-11CE-B03A-0020AF0BA770}
; === common entries for all systems ======================
RegWrite, REG_SZ, %node%\Software\Classes\AVIFile\Extensions\AVS, , {E6D6B700-124D-11D4-86F3-DB80AFD98778}
RegWrite, REG_SZ, %node%\Software\Classes\.avs, , avsfile
RegWrite, REG_SZ, %node%\Software\Classes\.avsi, , avs_auto_file
RegWrite, REG_SZ, %node%\Software\Classes\avsfile, , AviSynth Script
RegWrite, REG_SZ, %node%\Software\Classes\avsfile\DefaultIcon, , %staticIconPath%
RegWrite, REG_SZ, %node%\Software\Classes\avs_auto_file, , AviSynth Autoload Script
RegWrite, REG_SZ, %node%\Software\Classes\avs_auto_file\DefaultIcon, , %iconPath%
If (ErrorLevel) {
MsgBox There was a problem writing registry entries. The installation has be interrupted.
Return
}
MsgBox AviSynth installed.
return 1
}
AviSynthUninstall(dllPath,node="HKLM") {
; specify "HKCU" for HKey_Current_User key
; default is HKey_Local_Machine
If (InStr(dllPath,"x86") Or
. InStr(dllPath,"win32") Or
. InStr(dllPath,"win 32") Or
. InStr(dllPath,"win_32") Or
. InStr(dllPath,"x32") Or
. InStr(dllPath,"32-bit") Or
. InStr(dllPath,"32 bit") Or
. InStr(dllPath,"32bit")
. )
AvsArch := "x86"
Else If (InStr(dllPath,"x64") Or
. InStr(dllPath,"win64") Or
. InStr(dllPath,"win 64") Or
. InStr(dllPath,"win_64") Or
. InStr(dllPath,"64-bit") Or
. InStr(dllPath,"64 bit") Or
. InStr(dllPath,"64bit")
. )
AvsArch := "x64"
r := 1
MsgBox, 4, Uninstall AviSynth, Uninstalling %AvsArch% AviSynth`r`n`r`nContinue?
IfMsgBox, No
r := 0
If (r = 0)
return ; exit if user selects "NO"
fail := 0
If (A_Is64bitOS) { ; is a 64-bit OS
If (AvsArch = "x64") { ; 64-bit
regPath := ""
If (FileExist(A_WinDir "\System32\AviSynth.dll")) {
FileDelete, %A_WinDir%\System32\AviSynth.dll
if (ErrorLevel)
fail += ErrorLevel
}
If (FileExist(A_WinDir "\System32\DevIL.dll")) {
FileDelete, %A_WinDir%\System32\DevIL.dll
if (ErrorLevel)
fail += ErrorLevel
}
} Else { ; 32-bit
regPath := "Wow6432Node\"
If (FileExist(A_WinDir "\SysWOW64\AviSynth.dll")) {
FileDelete, %A_WinDir%\SysWOW64\AviSynth.dll
if (ErrorLevel)
fail := ErrorLevel
}
If (FileExist(A_WinDir "\SysWOW64\DevIL.dll")) {
FileDelete, %A_WinDir%\SysWOW64\DevIL.dll
if (ErrorLevel)
fail += ErrorLevel
}
}
} Else { ; is not 64-bit OS
regPath := ""
If (FileExist(A_WinDir "\System32\AviSynth.dll")) {
FileDelete, %A_WinDir%\System32\AviSynth.dll
if (ErrorLevel)
fail += ErrorLevel
}
If (FileExist(A_WinDir "\System32\DevIL.dll")) {
FileDelete, %A_WinDir%\System32\DevIL.dll
if (ErrorLevel)
fail += ErrorLevel
}
}
if (node = "HKCU")
regPath := ""
If (fail) {
MsgBox AviSynth was not able to be completely removed. Check to make sure you don't have any running scripts.
return
}
If (AvsArch = "x64")
otherOne := AviSynthX86
Else
otherOne := AviSynthX64
If (otherOne = "") { ; don't remove these keys if running 2 AviSynth versions
RegDelete, %node%\Software\Classes\AVIFile\Extensions\AVS
RegDelete, %node%\Software\Classes\.avs
RegDelete, %node%\Software\Classes\.avsi
RegDelete, %node%\Software\Classes\avsfile
RegDelete, %node%\Software\Classes\avs_auto_file
}
RegDelete, %node%\Software\%regPath%Avisynth
RegDelete, %node%\Software\%regPath%Classes\CLSID\{E6D6B700-124D-11D4-86F3-DB80AFD98778}
RegDelete, %node%\Software\%regPath%Classes\Media Type\Extensions\.avs
If (ErrorLevel) {
MsgBox There was a problem removing the registry entries. Please make sure a script is not running.
return
}
MsgBox AviSynth uninstall complete.
return 1
}