-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.aup
120 lines (106 loc) · 5.27 KB
/
setup.aup
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
#include <MsgBoxConstants.au3>
#include <TrayConstants.au3>
#include <FileConstants.au3>
Opt("MustDeclareVars", 1)
const SilentMode = False
const Au3exeDir = Replace(@AutoItExe, "AutoIt3.exe", "")
const TemplateFilePath = @WindowsDir . "\ShellNew\Template.aup"
if FileExists(Au3exeDir . "Plys\plys.aup.au3") then
Uninstall()
else
Install()
;··············································································
func Install()
;··············································································
dim answer
if not SilentMode then
answer = MsgBox(MB_OKCancel + MB_DefButton2, _
"Install Plys for AutoIt?", _
"Plys features for AutoIt will install to this computer.")
if answer <> IdOK then exit
TraySetIcon("stop")
TraySetState(Tray_IconState_Flash)
; RegWrite("HKLM\SOFTWARE\AutoIt v3", "PlysVersion", "REG_SZ", "1.0")
DirCreate(Au3exeDir . "Plys")
; copy translator and this file
Copy("plys.aup.au3", Au3exeDir . "Plys\", FC_Overwrite)
Copy(@ScriptFullPath, Au3exeDir . "Plys\uninstall.aup.au3", FC_Overwrite)
; copy template file
dim templFileData = Read(@WindowsDir . "\ShellNew\Template.au3")
templFileData = Replace(templFileData, "AutoIt", "AutoIt Plys")
templFileData = ReReplace(templFileData, _
"(AutoIt Plys Version:).*", "$1 " . @PlysVersion)
templFileData = ReReplace(templFileData, _
"(Author:\s+)(myName)", "$1 $2")
FileDelete(TemplateFilePath)
Write(TemplateFilePath, templFileData)
; copy icon, help and examples
Copy("aupscript.ico", Au3exeDir . "Plys\aupscript.ico", FC_Overwrite)
Copy("tray.ico", Au3exeDir . "Plys\tray.ico", FC_Overwrite)
Copy("Plys.chm", Au3exeDir . "Plys\Plys.chm", FC_Overwrite)
DirCopy("Helpfile Examples", Au3exeDir . "Plys\Helpfile Examples", _
FC_Overwrite)
RegWrite("HKCR\.aup", "", "REG_SZ", "AutoItPlysScript")
; appoint file type class
RegWrite("HKCR\.aup", "PerceivedType", "REG_SZ", "text")
; appoint to Windows search content in as plain text
RegWrite("HKCR\.aup\PersistentHandler", "", "REG_SZ", _
"{5e941d80-bf96-11cd-b579-08002b30bfeb}")
RegWrite("HKCR\.aup\ShellNew", "FileName", "REG_SZ", "Template.aup")
RegWrite("HKCR\AutoItPlysScript", "", "REG_SZ", "AutoIt Plys Script")
RegWrite("HKCR\AutoItPlysScript\DefaultIcon", "", "REG_SZ", _
Au3exeDir . "Plys\aupscript.ico")
RegWrite("HKCR\AutoItPlysScript\Shell", "", "REG_SZ", "Run")
; TODO: Compile–CompileX86
RegWrite("HKCR\AutoItPlysScript\Shell\Edit", "", "REG_SZ", "Edit Script")
const editCmd = RegRead("HKCR\AutoIt3Script\Shell\Edit\Command", "")
RegWrite("HKCR\AutoItPlysScript\Shell\Edit\Command", "", _
"REG_SZ", editCmd)
RegWrite("HKCR\AutoItPlysScript\Shell\Open", "", "REG_SZ", "Open Script")
const openCmd = RegRead("HKCR\AutoIt3Script\Shell\Open\Command", "")
RegWrite("HKCR\AutoItPlysScript\Shell\Open\Command", "", _
"REG_SZ", openCmd)
RegWrite("HKCR\AutoItPlysScript\Shell\Run", "", "REG_SZ", "Run Script")
const runCmd = RegRead("HKCR\AutoIt3Script\Shell\Run\Command", "")
const arg0 = ReReplace(runCmd, ' ".*', "")
const arg1 = Replace(arg0, "AutoIt3.exe", "Plys\plys.aup.au3")
RegWrite("HKCR\AutoItPlysScript\Shell\Run\Command", "", "REG_SZ", _
arg0 . " " . arg1 . ' /Rapid "%1" %*')
RegWrite("HKCR\AutoItPlysScript\Shell\Retranslate and Run", "", "REG_SZ", _
"Retranslate and Run")
RegWrite("HKCR\AutoItPlysScript\Shell\Retranslate and Run\Command", _
"", "REG_SZ", arg0 . " " . arg1 . ' "%1" %*')
; TODO: RunX64, RunX86
RegWrite("HKCR\AutoItPlysScript\Shell\Translate", "", "REG_SZ", _
"Translate to AutoIt")
RegWrite("HKCR\AutoItPlysScript\Shell\Translate\Command", "", _
"REG_SZ", arg0 . " " . arg1 . ' /Translate "%1"')
; HKLM\SOFTWARE\WOW6432Node\Microsoft\Windows\CurrentVersion
; \Uninstall\AutoItv3
TraySetState(Tray_IconState_StopFlash)
TraySetIcon()
if not SilentMode then
MsgBox(MB_OK + MB_DefButton2, "Success", _
"Plys for AutoIt is installed.")
func Uninstall()
dim answer
if not SilentMode then
answer = MsgBox(MB_OKCancel + MB_DefButton2, _
"Uninstall Plys for AutoIt?", _
"Plys already installed. Uninstalling Plys will delete" _
. " existing data of plys.aup.au3 file.")
if answer <> IdOK then exit
TraySetIcon("stop")
TraySetState(Tray_IconState_Flash)
FileDelete(TemplateFilePath)
while not DirRemove(Au3exeDir . "Plys", Dir_Remove)
answer = MsgBox(MB_RetryCancel + MB_IconError, "Failure", _
"Unable to delete Plys folder.")
if answer = IdCancel then return
RegDelete("HKCR\.aup")
RegDelete("HKCR\AutoItPlysScript")
TraySetState(Tray_IconState_StopFlash)
TraySetIcon()
if not SilentMode then
MsgBox(MB_OK + MB_DefButton2, "Success", _
"Plys for AutoIt is uninstalled.")