-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.ahk2
140 lines (108 loc) · 4.28 KB
/
Main.ahk2
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
; make sure to use the correct version
#Requires AutoHotkey v2.0-
#SingleInstance Force ; Only one instance allowed
SetWorkingDir(A_InitialWorkingDir)
; Language definitions
#Include Languages.ahk2
; detect language (defaults to english)
languageSelection := languages.en
if RegExMatch(A_Language, "..07") ; every language code with xx07 means german
languageSelection := languages.de
; place for configs
configDir := EnvGet("LocalAppdata") . "\WindowsTerminalQuakeTrayIcon\"
configFile := configDir . "config.ini"
; pre-start checks (not necessary if not first start)
if IniRead(configFile, "Configs", "FirstStart", true) {
; check if the correct version of Windows Terminal is installed
ready := false
if VerCompare(A_OSVersion, "10.0") < 0 {
MsgBox(languageSelection.noWin10P,, 16)
ExitApp()
}
try {
Run("wt.exe --help")
While not WinExist("ahk_class #32770 ahk_exe WindowsTerminal.exe")
Sleep(250)
if InStr(WinGetText(), "-w,--window TEXT") {
WinClose()
ready := true
}
} finally {
if ready {
if not DirExist(configDir)
DirCreate(configDir)
if not FileExist(configFile)
FileAppend("
(LTrim
[Configs]
; Here you can tweak some basic settings
; FirstStart: Boolean (0 or 1; 0 means false, 1 means true)
; Whether the program was started more than once or not
FirstStart=0
[Hotkey]
; Here you can set a custom key-combo with up to three keys
; NOTE:
; You have to use the hotkeys defined by AutoHotkey V2 (read the docs)
; https://lexikos.github.io/v2/docs/Hotkeys.htm
; Some basic keys:
; Every letter or number can be used by defining it as it is
; CTRL can be used like this:
; LCtrl for the left and RCtrl for the right CTRL key
; LShift for the left and RShift for the right shift key
; Alt: LAlt for left Alt key / RAlt for right Alt key
; Windows key: LWin (or RWin - probably not useful)
; F1-F24 can be used as they are
; Esc can also be used as it is
; Key1: Key on your keyboard / first of maximal three keys to be pressed
; Key2: Key on your keyboard / second of maximal three keys to be pressed
; Key3: Key on your keyboard / third of maximal three keys to be pressed
; Default: LWin + LShift + `` (like in Windows Terminal)
Key1=LWin
Key2=LShift
Key3=``
)", configFile, "`n")
if not A_ScriptFullPath = configDir . A_ScriptName {
if not A_IsCompiled {
FileCopy(A_ScriptFullPath, configDir . "Languages.ahk2", true)
FileCopy(A_ScriptFullPath, configDir . "TrayIcon.ahk2", true)
}
FileCopy(A_ScriptFullPath, configDir . A_ScriptName, true)
}
FileCreateShortcut(configDir . A_ScriptName, A_Startup . "\" . A_ScriptName . ".lnk", configDir)
Run(configDir . A_ScriptName) ; this one could be a problem...
ExitApp()
} else {
MsgBox(languageSelection.noWTError,, 16)
ExitApp()
}
}
}
; Load configs
loadConfigs() {
key1 := IniRead(configFile, "Hotkey", "Key1")
key2 := IniRead(configFile, "Hotkey", "Key2")
key3 := IniRead(configFile, "Hotkey", "Key3")
return
}
; loadConfigs()
; uninstall:
; remove shirtcut from shell:startup
; delete configDir recursively
Uninstall() {
if DirExist(configDir)
DirDelete(configDir, true)
return
}
; Run the detected command
showTerminal() {
return
}
; Open settings.ini in standard editor
openSettings() {
RunWait(configFile)
; Reload configs
loadConfigs()
return
}
; code for tray icon
#Include TrayIcon.ahk2