-
Notifications
You must be signed in to change notification settings - Fork 22
/
PowerToolsBundler.ahk
362 lines (318 loc) · 11.2 KB
/
PowerToolsBundler.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
#SingleInstance force
#Include <PowerTools>
#Include <AHK>
#Include <Login>
; Calls: Lib/ToStartup
LastCompiled = 20220314141503
;IcoFile := RegExReplace(A_ScriptFullPath,"\..*",".ico")
IcoFile := PathX(A_ScriptFullPath, "Ext:.ico").Full
If (FileExist(IcoFile))
Menu,Tray,Icon, %IcoFile%
AppList = ConnectionsEnhancer,NWS,OutlookShortcuts,PeopleConnector,TeamsShortcuts,TeamsyLauncher,Teamsy,Atlasy,Mute,Cursor Highlighter
Config := PowerTools_GetConfig()
If (Config = "Conti")
AppList = MO,%AppList%
sGuiTitle = PowerTools Bundler
Gui, PTBundler:New,,%sGuiTitle%
; ListView
Gui, Add, ListView, h200 w180 Checked, %sGuiTitle% ; Create a ListView.
ImageListID := IL_Create(9) ; Create an ImageList to hold 10 small icons.
LV_SetImageList(ImageListID) ; Assign the above ImageList to the current ListView.
IconCount := 0
Loop, Parse, AppList, `,
{ ; Load the ImageList with a series of icons from the DLL.
If a_iscompiled
IcoFile = %A_ScriptDir%\%A_LoopField%.exe
Else
IcoFile = %A_ScriptDir%\%A_LoopField%.ico
If FileExist(IcoFile) {
IL_Add(ImageListID,IcoFile)
IconCount := IconCount +1
LV_Add("Icon" . IconCount , A_LoopField)
} Else
LV_Add("Icon10" , A_LoopField)
} ; End Loop
LV_ModifyCol() ; Auto-adjust the column widths.
; https://jacksautohotkeyblog.wordpress.com/2019/12/30/use-autohotkey-gui-menu-bar-for-instant-hotkeys/
; MenuBar
Menu, ItemsMenu, Add, Check All`tCtrl+A, PTBSelectAll
Menu, ItemsMenu, Add, Uncheck all`tCtrl+Shift+A, PTBUncheckAll
If !a_iscompiled {
Menu, ActionsMenu, Add, &Compile`tCtrl+C, Compile
Menu, ActionsMenu, Add, Compile And &Push`tCtrl+P, CompileAndPush
Menu, ActionsMenu, Add, &Tweet`tCtrl+T, Tweet
Menu, ActionsMenu, Add, Compile Bundler, CompileSelf
Menu, ActionsMenu, Add, &Developper Mode`tCtrl+D, DevMode
Menu, ActionsMenu, Add, Exe Mode, ExeMode
} Else {
Menu, ActionsMenu, Add, Check for &Update/Download`tCtrl+U, CheckForUpdate
}
Menu, ActionsMenu, Add, Add to &Startup`tCtrl+S, AddToStartup
Menu, ActionsMenu, Add, &Run`tCtrl+R, Run
Menu, ActionsMenu, Add, E&xit`tCtrl+X, Exit
Menu, ActionsMenu, Add, Open Help`tCtrl+H, OpenHelp
Menu, ActionsMenu, Add, Open Change&log`tCtrl+L, OpenChangelog
Menu, ActionsMenu, Add, Open &News`tCtrl+N, OpenNews
Menu, SettingsMenu, Add, Load Config, LoadConfig
Menu, SettingsMenu, Add, Open ini file, OpenIni
Menu, SettingsMenu, Add, Notification at Startup, MenuCb_ToggleSettingNotificationAtStartup
RegRead, SettingNotificationAtStartup, HKEY_CURRENT_USER\Software\PowerTools, NotificationAtStartup
If (SettingNotificationAtStartup = "")
SettingNotificationAtStartup := True ; Default value
If (SettingNotificationAtStartup) {
Menu, SettingsMenu, Check, Notification at Startup
} Else {
Menu, SettingsMenu, UnCheck, Notification at Startup
}
Menu, HelpMenu, Add, Open Help, OpenPTHelp
Menu, HelpMenu, Add, Check for Update, CheckForUpdateSelf
Menu, HelpMenu, Add, Open Change&log, OpenPTChangelog
Menu, MyMenuBar, Add, &Items, :ItemsMenu
Menu, MyMenuBar, Add, &Actions, :ActionsMenu
Menu, MyMenuBar, Add, &Settings, :SettingsMenu
Menu, MyMenuBar, Add, &Help, :HelpMenu
Gui, Menu, MyMenuBar
Gui, Show
Return
; -------------------------------------------------------------------------------------------------------------------
OpenIni:
sIniFile = %A_ScriptDir%\PowerTools.ini
If FileExist(sIniFile)
Run, notepad.exe %sIniFile%
Return
; -------------------------------------------------------------------------------------------------------------------
LoadConfig:
PowerTools_LoadConfig()
return
PTBSelectAll:
LV_Modify(0, "Check") ; Uncheck all the checkboxes.
return
PTBUncheckAll:
LV_Modify(0, "-Check") ; Uncheck all the checkboxes.
return
; -------------------------------------------------------------------------------------------------------------------
CheckForUpdateSelf:
PowerTools_CheckForUptate()
return
; -------------------------------------------------------------------------------------------------------------------
CheckForUpdate: ; CFU
; warning if connected via VPN
If (Login_IsVPN()) {
MsgBox, 0x1011, CheckForUpdate with VPN?,It seems you are connected with VPN.`nCheck for update might not work. Consider disconnecting VPN.`nContinue now?
IfMsgBox Cancel
return
}
RowNumber = 0
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
PowerTools_CheckForUptate(ItemName)
}
; Update PowerTools.ini - only once
IniFile = %A_ScriptDir%\PowerTools.ini
sUrl = https://github.com/tdalon/ahk/raw/main/PowerTools/PowerTools.ini
If Not FileExist(IniFile) {
UrlDownloadToFile, %sUrl%, %IniFile%
} Else {
guExe = %A_ScriptDir%\github_updater.exe
If Not FileExist(guExe)
UrlDownloadToFile, https://github.com/tdalon/ahk/raw/main/PowerTools/github_updater.exe, %guExe%
UrlDownloadToFile, %sUrl%, PowerTools.ini.github
sCmd = %guExe% PowerTools.ini
RunWait, %sCmd%,,Hide
}
; open directory
Run %A_ScriptDir%
return
; -------------------------------------------------------------------------------------------------------------------
OpenPTHelp:
PowerTools_Help("Bundler")
return
; -------------------------------------------------------------------------------------------------------------------
Exit:
RowNumber = 0
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
If a_iscompiled
ScriptFullPath = %A_ScriptDir%\%ItemName%.exe
Else
ScriptFullPath = %A_ScriptDir%\%ItemName%.ahk
AHK_Exit(ScriptFullPath)
}
return
; -------------------------------------------------------------------------------------------------------------------
OpenChangelog:
RowNumber = 0
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
PowerTools_Changelog(ItemName)
}
return
; -------------------------------------------------------------------------------------------------------------------
OpenNews:
RowNumber = 0
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
PowerTools_News(ItemName)
}
return
; -------------------------------------------------------------------------------------------------------------------
OpenHelp:
RowNumber = 0
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
PowerTools_Help(ItemName)
}
return
; -------------------------------------------------------------------------------------------------------------------
Compile:
RowNumber = 0
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
ScriptFullPath = %A_ScriptDir%\%ItemName%.ahk
AHK_Compile(ScriptFullPath,,"PowerTools")
}
Run %A_ScriptDir%\PowerTools
return
; -------------------------------------------------------------------------------------------------------------------
CompileSelf:
AHK_Compile(A_ScriptFullPath,,"PowerTools")
return
; -------------------------------------------------------------------------------------------------------------------
CompileAndPush:
RowNumber = 0
FileList =
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
ScriptFullPath = %A_ScriptDir%\%ItemName%.ahk
AHK_Compile(ScriptFullPath,,"PowerTools")
FileList = %FileList% %ItemName%.exe
; Add changelog
cl := PowerTools_Changelog(ItemName,False)
cl := RegExReplace(cl,".*\","")
FileList = %FileList% %cl%
}
RunWait, git add %FileList%, %A_ScriptDir%\PowerTools
RunWait, git commit -m "Update compiled powertools", %A_ScriptDir%\PowerTools
RunWait, git push origin master, %A_ScriptDir%\PowerTools
return
Tweet:
RowNumber = 0
FileList =
Loop {
RowNumber := LV_GetNext(RowNumber, "Checked")
if not RowNumber
break
LV_GetText(ItemName, RowNumber, 1)
PowerTools_TweetPush(ItemName)
}
return
; -------------------------------------------------------------------------------------------------------------------
AddToStartup:
RowNumber = 0
Loop % LV_GetCount()
{
RowNumber := A_Index
SendMessage, 4140, RowNumber - 1, 0xF000, SysListView321 ; 4140 is LVM_GETITEMSTATE. 0xF000 is LVIS_STATEIMAGEMASK.
IsChecked := (ErrorLevel >> 12) - 1 ; This sets IsChecked to true if RowNumber is checked or false otherwise.
LV_GetText(ItemName, RowNumber, 1)
If (ItemName = "Teamsy") ; Skip Teamsy -> TeamsyLauncher shall be used instead
Continue
If a_iscompiled
ScriptFullPath = %A_ScriptDir%\%ItemName%.exe
Else
ScriptFullPath = %A_ScriptDir%\%ItemName%.ahk
ToStartup(ScriptFullPath,IsChecked)
}
Run %A_Startup%
return
; -------------------------------------------------------------------------------------------------------------------
Run:
RowNumber = 0
Loop % LV_GetCount()
{
RowNumber := A_Index
SendMessage, 4140, RowNumber - 1, 0xF000, SysListView321 ; 4140 is LVM_GETITEMSTATE. 0xF000 is LVIS_STATEIMAGEMASK.
IsChecked := (ErrorLevel >> 12) - 1 ; This sets IsChecked to true if RowNumber is checked or false otherwise.
LV_GetText(ItemName, RowNumber, 1)
If a_iscompiled
ScriptFullPath = %A_ScriptDir%\%ItemName%.exe
Else
ScriptFullPath = %A_ScriptDir%\%ItemName%.ahk
If IsChecked {
If !FileExist(ScriptFullPath) {
TrayTip, PowerTools Bundler: Run, % ScriptFullPath " not available!"
break
}
Run, %ScriptFullPath%
} Else
AHK_Exit(ScriptFullPath)
}
return
; -------------------------------------------------------------------------------------------------------------------
StartMO:
Run %A_ScriptDir%\PowerTools\MO.exe
return
; -------------------------------------------------------------------------------------------------------------------
OpenPTChangelog:
PowerTools_Changelog("Bundler")
return
; -------------------------------------------------------------------------------------------------------------------
DevMode:
;DevList = ConnectionsEnhancer,NWS,OutlookShortcuts,PeopleConnector,TeamsShortcuts
Loop, Parse, AppList, `,
{
ScriptFullPath = %A_ScriptDir%\%A_LoopField%.ahk
Run, %ScriptFullPath%
ScriptFullPath = %A_ScriptDir%\%A_LoopField%.exe
SplitPath,ScriptFullPath, FileName
sCmd = taskkill /f /im "%FileName%"
Run %sCmd%,,Hide
} ; End Loop
;Run %A_ScriptDir%\PowerTools\MO.exe
return
ExeMode:
Loop, Parse, AppList, `,
{
ScriptFullPath = %A_ScriptDir%\%A_LoopField%.ahk
AHK_Exit(ScriptFullPath)
ScriptFullPath = %A_ScriptDir%\PowerTools\%A_LoopField%.exe
Run, %ScriptFullPath%
} ; End Loop
return
; -------------------------------------------------------------------------------------------------------------------
MenuCb_ToggleSettingNotificationAtStartup:
If (SettingNotificationAtStartup := !SettingNotificationAtStartup) {
Menu, SettingsMenu, Check, Notification at Startup
}
Else {
Menu, SettingsMenu, UnCheck, Notification at Startup
}
PowerTools_RegWrite("NotificationAtStartup",SettingNotificationAtStartup)
return
; -------------------------------------------------------------------------------------------------------------------
PTBundlerGuiClose:
ExitApp
PTBundlerGuiEscape:
ExitApp
return