-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathTeamsShortcuts.ahk
431 lines (358 loc) · 12.1 KB
/
TeamsShortcuts.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
; MS Teams Keyboard Shortcuts
; Author: Thierry Dalon
; See user documentation here: https://connext.conti.de/blogs/tdalon/entry/teams_shortcuts_ahk
; Code Project Documentation is available on GitHub here: https://github.com/tdalon/ahk
; Source : https://github.com/tdalon/ahk/blob/master/TeamsShortcuts.ahk
;
LastCompiled = 20210114064703
#Include <Teams>
#Include <PowerTools>
#Include <WinClipAPI>
#Include <WinClip>
#SingleInstance force ; for running from editor
SubMenuSettings := PowerTools_MenuTray()
Menu, SubMenuSettings, Add, Teams PowerShell, MenuCb_ToggleSettingTeamsPowerShell
RegRead, TeamsPowerShell, HKEY_CURRENT_USER\Software\PowerTools, TeamsPowerShell
If (TeamsPowerShell)
Menu,SubMenuSettings,Check, Teams PowerShell
Else
Menu,SubMenuSettings,UnCheck, Teams PowerShell
Menu, SubMenuSettings, Add, Teams Personalize Mentions, MenuCb_ToggleSettingTeamsMentionPersonalize
TeamsMentionPersonalize := PowerTools_RegRead("TeamsMentionPersonalize")
If (TeamsMentionPersonalize)
Menu,SubMenuSettings,Check, Teams Personalize Mentions
Else
Menu,SubMenuSettings,UnCheck, Teams Personalize Mentions
Menu, SubMenuSettings, Add, Update Personal Information, GetMe
Menu, SubMenuSettings, Add, &Mute Hotkey, Teams_MuteHotkeySet
Menu,Tray,NoStandard
Menu,Tray,Add,Add to Teams Favorites, Link2TeamsFavs
Menu, SubMenuCustomBackgrounds, Add, Open Custom Backgrounds Folder, OpenCustomBackgrounds
Menu, SubMenuCustomBackgrounds, Add, Open Backgrounds Library, OpenCustomBackgroundsLibrary
Menu, Tray, Add, Custom Backgrounds, :SubMenuCustomBackgrounds
Menu, Tray,Add,Start Second Instance, Teams_OpenSecondInstance
Menu, Tray,Add,Clear Cache, Teams_ClearCache
Menu, Tray,Add,Open Web App, Teams_OpenWebApp
Menu, Tray,Add
Menu, Tray,Add,Export Team Members, Users2Excel
Menu, Tray,Add,Refresh Teams List, Teams_ExportTeams
Menu, Tray,Add
Menu, SubMenuMeeting, Add, Open Teams Web Calendar, Teams_OpenWebCal
; Add Cursor Highlighter
Menu, SubMenuMeeting, Add, Cursor Highlighter, PowerTools_CursorHighlighter
Menu, SubMenuMeeting, Add, Toggle Mute (Middle Click on Tray Icon), Teams_Mute
Menu, SubMenuMeeting, Add, Toggle Video (Right Click on Tray Icon), Teams_Video
Menu, SubMenuVLC, Add, Start VLC, VLCStart
Menu, SubMenuVLC, Add, Set Play Mode, VLCPlayMode
Menu, SubMenuVLC, Add, Reset, VLCReset
Menu, SubMenuMeeting, Add, VLC, :SubMenuVLC
Menu, Tray, Add, Meeting, :SubMenuMeeting
Menu, Tray,Add
Menu, Tray,Standard
; Tooltip
If !a_iscompiled
FileGetTime, LastMod , %A_ScriptFullPath%
Else
LastMod := LastCompiled
FormatTime LastMod, %LastMod% D1 R
sTooltip = Teams Shortcuts %LastMod%`nUse 'Win+T' to open main menu in Teams.`nClick on icon to access other functionalities.
Menu, Tray, Tip, %sTooltip%
; -------------------------------------------------------------------------------------------------------------------
Menu, TeamsShortcutsMenu, add, Smart &Reply (Alt+R), Teams_SmartReply
Menu, TeamsShortcutsMenu, add, &Quote Conversation (Alt+Q), QuoteConversation
Menu, TeamsShortcutsMenu, add, &New Expanded Conversation (Alt+N), NewConversation
Menu, TeamsShortcutsMenu, add, Create E&mail with link to current conversation (Win+M), ShareByMail
Menu, TeamsShortcutsMenu, add, Send Mentions (Win+Q), SendMentions
Menu, TeamsShortcutsMenu, add, Personalize &Mention (Win+1), PersonalizeMention
Menu, TeamsShortcutsMenu, add, View &Unread (Win+U), ViewUnread
Menu, TeamsShortcutsMenu, add, View &Saved (Win+S), ViewSaved
Menu, TeamsShortcutsMenu, add, &Pop-out Chat (Win+P), Pop
Menu, TeamsShortcutsMenu, add, Add to &Favorites, Link2TeamsFavs
; -------------------------------------------------------------------------------------------------------------------
; Reset Main WinId at startup because of some possible hwnd collision
PowerTools_RegWrite("TeamsMainWinId","")
; -------------------------------------------------------------------------------------------------------------------
; Setting - TeamsMuteHotkey
RegRead, TeamsMuteHotkey, HKEY_CURRENT_USER\Software\PowerTools, TeamsMuteHotkey
If (TeamsMuteHotkey != "") {
Teams_MuteHotkeyActivate(TeamsMuteHotkey)
}
Menu, TrayVideo, Add, Toggle Video..., DoNothing
Menu, TrayMute, Add, Toggle Mute..., DoNothing
return
; ########################## Hotkeys ##########################################
#IfWinActive,ahk_exe Teams.exe
#1:: ; <--- Personalize Mention
PersonalizeMention:
Teams_PersonalizeMention()
return
;--- Compose in Expand mode
; Alt + N
!n:: ; <--- New Expanded Conversation
NewConversation:
Teams_NewConversation()
return
; View Unread
; Win+U
#u:: ; <--- View Unread
ViewUnread:
If GetKeyState("Ctrl") {
Run, "https://connext.conti.de/blogs/tdalon/entry/teams_shortcuts_ahk"
return
}
Send ^e ; Select Search bar
SendInput /unread
Sleep 500
Send {Enter}
return
; View Saved
; Win+S
#s:: ; <--- View Saved
ViewSaved:
If GetKeyState("Ctrl") {
Run, "https://connext.conti.de/blogs/tdalon/entry/teams_shortcuts_ahk"
return
}
Send ^e ; Select Search bar
SendInput /saved
Sleep 500
Send {Enter}
return
; Pop-out chat
; Win+P
#p:: ; <--- Pop-out chat
Pop:
If GetKeyState("Ctrl") {
Run, "https://connext.conti.de/blogs/tdalon/entry/teams_shortcuts_ahk"
return
}
Send ^e ; Select Search bar
SendInput /pop
Sleep 500
Send {Enter}
return
; Alt+e
!e:: ; <--- Edit
Send {Enter}
Send {Tab}
Send {Enter}
Sleep 500
Send {Down 1}
Send {Enter}
return
; Alt+.
!.:: ; <--- (...) Actions menu
Send {Enter}
Send {Tab}
Send {Enter}
return
#t::
Menu, TeamsShortcutsMenu, Show
return
; Win+C
#c:: ; <--- Copy Link
TeamsCopyLink()
return
; -------------------------------------------------------------------------------------------------------------------
; Alt+R -
!r:: ; <--- Smart Reply with quotation and link to current thread
Teams_SmartReply()
return
; -------------------------------------------------------------------------------------------------------------------
; Alt+Q
!q:: ; <--- Quote conversation
QuoteConversation:
Teams_SmartReply(False)
return
; -------------------------------------------------------------------------------------------------------------------
!m:: ; <--- Create eMail with link to current conversation
ShareByMail:
If GetKeyState("Ctrl") {
;Run, "https://connext.conti.de/blogs/tdalon/entry/teams_smart_reply"
return
}
rc := TeamsCopyLink()
If (rc =false)
return
sHTMLBody = Hello<br>Following <a href="%clipboard%">this conversation</a> in Teams:
; Create Email using ComObj
Try
MailItem := ComObjActive("Outlook.Application").CreateItem(0)
Catch
MailItem := ComObjCreate("Outlook.Application").CreateItem(0)
;MailItem.BodyFormat := 2 ; olFormatHTML
MailItem.Subject := linktext
MailItem.HTMLBody := sHTMLBody
;******************************
;~ MailItem.Attachments.Add(NewFile)
MailItem.Display ;Make email visible
;~ mailItem.Close(0) ;Creates draft version in default folder
;MailItem.Send() ;Sends the email
; Select email body
Send {Tab 3}
Send {PgDn}
Send {Enter}
Send ^v
return
; ----------------------------------------------------------------------
#q::
SendMentions:
If GetKeyState("Ctrl") {
Run, "https://tdalon.blogspot.com/teams-shortcuts-send-mentions"
return
}
sEmailList := Clipboard
doPerso := PowerTools_RegRead("TeamsMentionPersonalize")
Teams_Emails2Mentions(sEmailList, doPerso)
return
; ----------------------------------------------------------------------
Link2TeamsFavs:
If GetKeyState("Ctrl") {
Run, "https://connext.conti.de/blogs/tdalon/entry/teams_shortcuts_favorites"
return
}
sUrl := clipboard
Link2TeamsFav(sUrl)
return
; ----------------------------------------------------------------------
Users2Excel:
TeamLink := Clipboard
sPat = \?groupId=([^&]*)
If (RegExMatch(TeamLink,sPat,sId)) {
sGroupId := sId1
Teams_Users2Excel(sGroupId)
} Else
Teams_Users2Excel()
return
; ----------------------------------------------------------------------
OpenCustomBackgrounds:
If GetKeyState("Ctrl") {
Run, "https://tdalon.blogspot.com/2021/01/teams-custom-backgrounds.html#openfolder"
return
}
Run, %A_AppData%\Microsoft\Teams\Backgrounds\Uploads
return
OpenCustomBackgroundsLibrary:
If GetKeyState("Ctrl") {
Run, "https://tdalon.blogspot.com/2021/01/teams-custom-backgrounds.html#openlib"
return
}
sIniFile = %A_ScriptDir%\PowerTools.ini
If !FileExist(sIniFile) {
TrayTipAutoHide("Error!","PowerTools.ini file is missing!",2000,3)
return
}
IniRead, CustomBackgroundsLibrary, %sIniFile%, MicrosoftTeams, TeamsCustomBackgroundsLibrary
If (CustomBackgroundsLibrary != "ERROR")
Run, "%CustomBackgroundsLibrary%"
Else {
Run, notepad.exe %sIniFile%
TrayTipAutoHide("Background Library!","Background Library location is configured in PowerTools.ini TeamsCustomBackgroundsLibrary parameter.")
}
return
; ----------------------------------------------------------------------
GetMe:
If GetKeyState("Ctrl") {
Run, "https://tdalon.blogspot.com/2020/11/teams-shortcuts-smart-reply.html#getme"
return
}
suc := People_GetMe()
If (suc) {
TrayTipAutoHide("Personal information updated!","Email, OfficeUid, Display Name were stored to the registry.")
}
return
; ----------------------------------------------------------------------
CursorHighliter:
Run %CHFile%
return
DoNothing:
return
; ######################################################################
PersonalizeMentions:
; Does not work!
Send ^a
sHtml := GetSelection("html")
sPat = Us)<span .* itemtype="http://schema.skype.com/Mention".*>(.*)</span>
sNewHtml := sHtml
Pos = 1
While Pos := RegExMatch(sHtml,sPat,sFullName,Pos+StrLen(sFullName)){
sFullName1 := RegExReplace(sFullName1," (.*)","")
FirstName := RegExReplace(sFullName1,".*, ","")
sNewHtml := StrReplace(sNewHtml,sFullName1,FirstName)
}
;sNewHtml := RegExReplace(sNewHtml,"s).*<html>","<html>")
WinClip.SetHTML(sNewHtml)
WinClip.Paste()
return
; ######################################################################
NotifyTrayClick_208: ; Middle click (Button up)
Teams_Mute()
Menu_Show(MenuGetHandle("TrayMute"), False, Menu_TrayParams()*)
;Menu, Tray, Tip, Toggle Mute
;SetTimer, ResetToolTip, 1000
Return
NotifyTrayClick_202: ; Left click (Button up)
Menu_Show(MenuGetHandle("Tray"), False, Menu_TrayParams()*)
Return
NotifyTrayClick_205: ; Right click (Button up)
Teams_Video()
Menu_Show(MenuGetHandle("TrayVideo"), False, Menu_TrayParams()*)
Return
; ---------------------------- FUNCTIONS ------------------------------------------
MeetingSetup(){
; Open Teams Calendar in the Browser
Teams_OpenWebCal()
}
VLCStart() {
If !WinActive("ahk_exe vlc.exe") {
WinActivate, ahk_exe vlc.exe
If !WinActive("ahk_exe vlc.exe") {
VLCExe := PowerTools_RegGet("VLCExe")
If (VLCExe = "")
return
Run, %VLCExe%
}
WinWaitActive, ahk_exe vlc.exe
}
Send ^c ; Configure Capture Device
} ; eofun
; ----------------------------------------------------------------------
VLCPlayMode(){
If !WinActive("ahk_exe vlc.exe") {
WinActivate, ahk_exe vlc.exe
If !WinActive("ahk_exe vlc.exe") {
VLCStart()
return
}
}
SendInput ^h ; Minimal Interface
WinSet, AlwaysOnTop , On, ahk_exe vlc.exe
WinSet, Style, -0xC00000, ahk_exe vlc.exe ; remove title bar
} ; eofun
; ----------------------------------------------------------------------
VLCReset(){
If !WinActive("ahk_exe vlc.exe") {
WinActivate, ahk_exe vlc.exe
If !WinActive("ahk_exe vlc.exe") {
VLCStart()
return
}
}
WinSet, Style, -0xC00000, ahk_exe vlc.exe ; toggle title bar
SendInput ^h ; Minimal Interface
WinSet, AlwaysOnTop , Off, ahk_exe vlc.exe
} ; eofun
; ----------------------------------------------------------------------
; https://www.autohotkey.com/boards/viewtopic.php?t=81157
NotifyTrayClick(P*) { ; v0.41 by SKAN on D39E/D39N @ tiny.cc/notifytrayclick
Static Msg, Fun:="NotifyTrayClick", NM:=OnMessage(0x404,Func(Fun),-1), Chk,T:=-250,Clk:=1
If ( (NM := Format(Fun . "_{:03X}", Msg := P[2])) && P.Count()<4 )
Return ( T := Max(-5000, 0-(P[1] ? Abs(P[1]) : 250)) )
Critical
If ( ( Msg<0x201 || Msg>0x209 ) || ( IsFunc(NM) || Islabel(NM) )=0 )
Return
Chk := (Fun . "_" . (Msg<=0x203 ? "203" : Msg<=0x206 ? "206" : Msg<=0x209 ? "209" : ""))
SetTimer, %NM%, % (Msg==0x203 || Msg==0x206 || Msg==0x209)
? (-1, Clk:=2) : ( Clk=2 ? ("Off", Clk:=1) : ( IsFunc(Chk) || IsLabel(Chk) ? T : -1) )
Return True
}