forked from dpeluso/ahk-1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPeopleConnector.ahk
549 lines (487 loc) · 17.8 KB
/
PeopleConnector.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
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
; Author: Thierry Dalon
; Standalone AHK File also delivered as compiled Standalone EXE file
; See help/homepage: https://tdalon.github.io/ahk/People-Connector
; Calls: ExtractEmails, TrayTipAutoHide, ToStartup
LastCompiled = 20210308194552
#SingleInstance force ; for running from editor
#Include <Clip>
#Include <People>
#Include <Connections>
#Include <Teams>
#Include <PowerTools>
#Include <WinActiveBrowser>
PT_Config := PowerTools_GetConfig()
RegRead, PT_TeamsOnly, HKEY_CURRENT_USER\Software\PowerTools, TeamsOnly
PowerTools_ConnectionsRootUrl := PowerTools_RegRead("ConnectionsRootUrl")
SubMenuSettings := PowerTools_MenuTray()
; -------------------------------------------------------------------------------------------------------------------
; SETTINGS
Menu, SubMenuSettings, Add,Set Password, Login_SetPassword
Menu, SubMenuSettings, Add, Notification at Startup, MenuCb_ToggleSettingNotificationAtStartup
RegRead, SettingNotificationAtStartup, HKEY_CURRENT_USER\Software\PowerTools, NotificationAtStartup
If (SettingNotificationAtStartup = "")
SettingNotificationAtStartup := True ; Default value
If (SettingNotificationAtStartup) {
Menu, SubMenuSettings, Check, Notification at Startup
}
Else {
Menu, SubMenuSettings, UnCheck, Notification at Startup
}
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
; -------------------------------------------------------------------------------------------------------------------
If !a_iscompiled
FileGetTime, LastMod , %A_ScriptFullPath%
Else
LastMod := LastCompiled
FormatTime LastMod, %LastMod% D1 R
sTextMenuTip = Double Tap 'Shift' to open menu.`nClick on icon to access Help.
Menu, Tray, Tip, People Connector - %LastMod%`n%sTextMenuTip%
sText = Double Tap 'Shift' to open menu after selection.`nClick on icon to access Help/ Support/ Check for Updates/ Settings.
If (SettingNotificationAtStartup)
TrayTip "People Connector is running!", %sText%
;TrayTipAutoHide("People Connector is running!",sText)
Menu, MainMenu, add, Teams &Chat, TeamsChat
Menu, MainMenu, add, Teams &Pop out Chat, TeamsPop
Menu, MainMenu, add, &Teams Call, TeamsCall
Menu, MainMenu, add, Create Teams Meeting, TeamsMeet
Menu, MainMenu, add, Add to Teams &Favorites, Emails2TeamsFavs
Menu, MainMenu, add, Add Users to Team, Emails2TeamUsers
Menu, MainMenu, add, Teams Chat - Copy Link, TeamsChatCopyLink
Menu, MainMenu,Add ; Separator
If !(PT_TeamsOnly)
Menu, MainMenu, add, &Skype Chat, SkypeChat
Menu, MainMenu, add, Soft Phone Call, Tel
Menu, MainMenu,Add ; Separator
Menu, MainMenu, add, Create &Email, MailTo
Menu, MainMenu, add, Create Outlook &Meeting, MeetTo
Menu, MainMenu, add, (Outlook) Meeting to Emails, Meeting2Emails
Menu, MainMenu, add, (Outlook) Meeting Recipients to Excel, Meeting2Excel
If (PowerTools_ConnectionsRootUrl != "") {
Menu, MainMenu, add, Copy Connections &at-Mentions, CNEmail2Mention
Menu, MainMenu,Add ; Separator
Menu, MainMenu, add, &Open Connections Profile, CNOpenProfile
Menu, MainMenu, add, Open Connections Network, CNOpenNetwork
}
Menu, MainMenu,Add ; Separator
Menu, MainMenu, add, Open &Delve, Delve
Menu, MainMenu, add, Open Delve Profile, DelveProfile
Menu, MainMenu, add, &Bing Search, BingSearch
Menu, MainMenu, add, &LinkedIn Search By Name, LinkedInSearch
Menu, MainMenu, add, Stream Profile, StreamProfile
If (PT_Config = "Conti")
Menu, MainMenu, add, People&View OrgChart (MySuccess), PeopleView
Menu, MainMenu,Add ; Separator
Menu, MainMenu, add, Copy Office &Uids, Emails2Uids
Menu, MainMenu, add, Copy Windows Uids, Emails2WinUids
Menu, MainMenu, add, Copy Windows Uids with Domain, Emails2DUids
Menu, MainMenu, add, Uids to Emails, winUids2Emails
Menu, MainMenu, add, Copy Emails, CopyEmails
Menu, MainMenu,Add ; Separator
If (PowerTools_ConnectionsRootUrl != "") {
Menu, SubMenuCNMentions, add, &Emails, ConNextMentions2Emails
Menu, SubMenuCNMentions, add, &Teams Chat, ConNextMentions2TeamsChat
Menu, SubMenuCNMentions, add, &Mentions (extract), ConNextMentions2Emails
Menu, MainMenu, add, (Connections) Mentions to, :SubMenuCNMentions
}
Menu, MainMenu, add, Emails to Excel, Emails2Excel
return
Shift:: ; (Double Press) <--- Open People Connector Menu
If (A_PriorHotKey = A_ThisHotKey and A_TimeSincePriorHotkey < 500) {
sSelection := People_GetSelection()
If (PowerTools_ConnectionsRootUrl != "") {
If WinActiveBrowser()
Menu, MainMenu, Enable, (Connections) Mentions to
Else
Menu, MainMenu, Disable, (Connections) Mentions to
}
If WinActive("ahk_exe Outlook.exe") {
Menu, MainMenu, Enable, (Outlook) Meeting to Emails
Menu, MainMenu, Enable, (Outlook) Meeting Recipients to Excel
} Else {
Menu, MainMenu, Disable, (Outlook) Meeting to Emails
Menu, MainMenu, Disable, (Outlook) Meeting Recipients to Excel
}
Menu, MainMenu, Show
}
return
; ######################################################################
NotifyTrayClick_202: ; Left click (Button up)
Menu_Show(MenuGetHandle("Tray"), False, Menu_TrayParams()*)
Return
NotifyTrayClick_205: ; Right click (Button up)
Return
; ---------------------------- Menu Callbacks -------------------------------------
TeamsChat:
sEmailList := People_GetEmailList(sSelection)
;MsgBox % sEmailList ; DBG
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Teams_Emails2Chat(sEmailList)
;If InStr(sEmailList,";") ; multiple Emails
; Teams_Emails2ChatDeepLink(sEmailList, askOpen:= true)
;Else {
; EnvGet, userprofile , userprofile
; Run, %userprofile%\AppData\Local\Microsoft\Teams\current\Teams.exe sip:%sEmailList%
; Run, msteams://teams.microsoft.com/l/chat/0/0?users=%sEmailList%
;}
return
; ------------------------------------------------------------------
TeamsMeet:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Teams_Emails2Meeting(sEmailList)
return
; ------------------------------------------------------------------
TeamsPop:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Teams_Pop(sEmailList)
return
; ------------------------------------------------------------------
TeamsChatCopyLink:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Teams_Emails2ChatDeepLink(sEmailList)
return
TeamsCall:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
If InStr(sEmailList,";") { ; multiple Emails
TrayTipAutoHide("People Connector warning!","Feature does not work for multiple users!")
return
} Else {
EnvGet, userprofile , userprofile
Run, %userprofile%\AppData\Local\Microsoft\Teams\current\Teams.exe callto:%sEmailList%
}
return
; ------------------------------------------------------------------
SkypeChat:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
If InStr(sEmailList,";") { ; multiple Emails
TrayTipAutoHide("People Connector warning!","Feature does not work for multiple users!")
return
} Else {
sSip :=RegExReplace(sEmailList, "@.*","@continental.com")
sCmd = "C:\Program Files (x86)\Microsoft Office\root\Office16\lync.exe" sip:%sSip%
Run, %sCmd%
}
return
; ------------------------------------------------------------------
Tel:
sEmailList := People_GetEmailList(sSelection)
If !sEmailList { ; empty
If !RegexMatch(sSelection,"[1-9\(\)-\s]*") {
TrayTipAutoHide("People Connector warning!","You shall have an email or phone number selected!")
} Else {
sTelNum := StrReplace(sSelection, " ","")
sTelNum := StrReplace(sTelNum, "-","")
; If number starts with 0 prepend a 0
If SubStr(sTelNum, 1, 1) = "0" {
sTelNum := SubStr(sTelNum, 2)
sTelNum = +49%sTelNum%
}
Run tel:%sTelNum%
}
return
}
If InStr(sEmailList,";") { ; multiple Emails
TrayTipAutoHide("People Connector warning!","Feature does not work for multiple users!")
return
} Else {
Run tel:%sEmailList%
}
return
; ------------------------------------------------------------------
Im:
sEmailList := People_GetEmailList(sSelection)
If !sEmailList { ; empty
return
}
sEmailList := StrReplace(sEmailList, ";",",")
;MsgBox %sEmailList%
Run im:%sEmailList%
return
CNEmail2Mention:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
sHtmlMentions := Connections_Emails2Mentions(sEmailList)
Clip_SetHtml(sHtmlMentions)
TrayTipAutoHide("People Connector","Mentions were copied to clipboard in RTF!")
return
ConNextMentions2Mentions:
;sHtml := GetSelection("html")
sHtml := CNMentions2Mentions(sSelection)
Clip_SetHtml(sHtml)
TrayTipAutoHide("Copy Mentions", "Mentions were copied to the clipboard in RTF!")
return
ConNextMentions2TeamsChat:
sEmailList := CNMentions2Emails(sSelection)
Teams_Emails2ChatDeepLink(sEmailList)
return
ConNextMentions2Emails:
sEmailList := CNMentions2Emails(sSelection)
Clip_Set(sEmailList)
TrayTipAutoHide("Copy Emails", "Emails were copied to the clipboard!")
return
; ------------------------------------------------------------------
CopyEmails:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Clip_Set(sEmailList)
TrayTipAutoHide("Copy Emails", "Emails were copied to the clipboard!")
return
Emails2Uids:
If GetKeyState("Ctrl") {
Run, "https://connext.conti.de/blogs/tdalon/entry/people_connector_get_userid"
return
}
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
sUidList := People_Emails2Uids(sEmailList)
clipboard := sUidList
TrayTipAutoHide("Copy Uid","Uids " . sUidList . " were copied to the clipboard!")
return
Emails2WinUids:
If GetKeyState("Ctrl") {
Run, "https://connext.conti.de/blogs/tdalon/entry/people_connector_get_userid"
return
}
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
sUidList := People_Emails2Uids(sEmailList,"sAMAccountName")
clipboard := sUidList
TrayTipAutoHide("Copy Uid","Uids " . sUidList . " were copied to the clipboard!")
return
Emails2DUids:
If GetKeyState("Ctrl") {
Run, "https://connext.conti.de/blogs/tdalon/entry/people_connector_get_domainuserid"
return
}
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
sUidList := People_Emails2DUids(sEmailList)
clipboard := sUidList
TrayTipAutoHide("Copy Uid","Domain\Uids " . sUidList . " were copied to the clipboard!")
return
; ------------------------------------------------------------------
winUids2Emails:
sEmailList := winUids2Emails(sSelection)
clipboard := sEmailList
TrayTipAutoHide("Copy Emails","Emails " . sEmailList . " were copied to the clipboard!")
return
; ------------------------------------------------------------------
Emails2TeamsFavs:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Teams_Emails2Favs(sEmailList)
return
; ------------------------------------------------------------------
Emails2TeamUsers:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Teams_Emails2Users(sEmailList)
return
; ------------------------------------------------------------------
Emails2Excel:
People_Emails2Excel(sSelection)
return
; ------------------------------------------------------------------
MailTo:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Try
MailItem := ComObjActive("Outlook.Application").CreateItem(0)
Catch
MailItem := ComObjCreate("Outlook.Application").CreateItem(0)
;MailItem.BodyFormat := 2 ; olFormatHTML
MailItem.To := sEmailList
MailItem.Display ;Make email visible
return
; ------------------------------------------------------------------
MeetTo:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Try
oItem := ComObjActive("Outlook.Application").CreateItem(1)
Catch
oItem := ComObjCreate("Outlook.Application").CreateItem(1)
;MailItem.BodyFormat := 2 ; olFormatHTML
oItem.MeetingStatus := 1
Loop, parse, sEmailList, ";"
{
oItem.Recipients.Add(A_LoopField)
}
oItem.Display ;Make email visible
return
; ------------------------------------------------------------------
Meeting2Emails:
oItem := Outlook_GetCurrentItem()
sEMailList := Outlook_Recipients2Emails(oItem)
Clip_Set(sEmailList)
TrayTipAutoHide("Meeting2Emails", "Attendees Emails were copied to the clipboard!")
return
; ------------------------------------------------------------------
Meeting2Excel:
Outlook_Meeting2Excel()
return
; ------------------------------------------------------------------
DelveProfile:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Loop, parse, sEmailList, ";"
{
Run, https://continental-my.sharepoint.com/person.aspx?user=%A_LoopField%&v=profiledetails
}
return
; ------------------------------------------------------------------
Delve:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList = "") {
TrayTipAutoHide("People Connector warning!","No email could be found!")
return
}
Loop, parse, sEmailList, ";"
{
Run, https://continental-my.sharepoint.com/person.aspx?user=%A_LoopField%
}
return
; ------------------------------------------------------------------
CNOpenProfile:
People_ConnectionsOpenProfile(sSelection)
return
CNOpenNetwork:
People_ConnectionsOpenNetwork(sSelection)
return
; ------------------------------------------------------------------
StreamProfile:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList != "") {
Loop, parse, sEmailList, ";"
{
Run, https://web.microsoftstream.com/browse?q=%A_LoopField%&view=people
}
} Else {
sName := People_GetName(sSelection)
Run, https://web.microsoftstream.com/browse?q=%sName%&view=people
}
return
; ------------------------------------------------------------------
LinkedInSearch:
sEmailList := People_GetEmailList(sSelection)
If (sEmailList != "") {
Loop, parse, sEmailList, ";"
{
sName:= People_Email2Name(A_LoopField)
Run, https://www.linkedin.com/search/results/people/?keywords=%sName%
}
} Else {
sName := People_GetName(sSelection)
Run, https://www.linkedin.com/search/results/people/?keywords=%sName%
}
return
; ------------------------------------------------------------------
LinkedInSearchByName:
sSelection := GetSelection()
sName := People_GetName(sSelection)
sName := RegExReplace(sName,"\d*","") ; remove any numbers
Run, https://www.linkedin.com/search/results/people/?keywords=%sName%
return
BingSearch:
sSelection := GetSelection()
sSelection := People_GetName(sSelection)
Run, http://www.bing.com/search?q=%sSelection%#,Person
return
PeopleView:
People_PeopleView(sSelection)
return
; ----------------------------------------------------------------------
ConNextAuth:
CNAuth()
return
; ----------------------------------------------------------------------
AddShortcutToADPhonebook:
EnvGet userprofile, userprofile
sLnk = %userprofile%\Desktop\Phonebook.lnk
sFile = \\cw01.contiwan.com\root\Loc\sbas\did43653\Public\SMT2009Tools\PusADTel\Release\PusADTel_OpenScape\PusADTel.exe
FileCreateShortcut, %sFile%, %sLnk%
TrayTipAutoHide("AD Phonebook","Shortcut was copied to your profile desktop")
return
; ----------------------------------------------------------------------
; ---------------------------------------------------------------------- STARTUP -------------------------------------------------
MenuCb_ToggleSettingNotificationAtStartup:
If (SettingNotificationAtStartup := !SettingNotificationAtStartup) {
Menu, SubMenuSettings, Check, Notification at Startup
}
Else {
Menu, SubMenuSettings, UnCheck, Notification at Startup
}
PowerTools_RegWrite("NotificationAtStartup",SettingNotificationAtStartup)
return
; ------------------------------- SUBFUNCTIONS ----------------------------------------------------------
; ----------------------------------------------------------------------
; 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
}