-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathNWS.ahk
1031 lines (867 loc) · 34.2 KB
/
NWS.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
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
; Author: Thierry Dalon
; Documentation: https://tdalon.github.io/ahk/NWS-PowerTool
; Code Project Documentation is available on GitHub here: https://github.com/tdalon/ahk
; Source: https://github.com/tdalon/ahk/blob/main/NWS.ahk
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
SetWorkingDir %A_ScriptDir%
include_cond("ET,Connections,Goodreads,Stackoverflow")
; creates %A_ScriptDir%\~NWS_includes.ahk. provide empty file with install or uncomment line below at first run
#Include %A_ScriptDir%\~NWS_includes.ahk
; A_ScriptDir is required
#Include <Clip>
#Include <IntelliPaste>
#Include <Login>
#Include <PowerTools>
#Include <Browser>
#Include <Teams>
#Include <SharePoint>
#Include <Explorer>
#Include <People>
; Optional Libaries - used if available
;#Include <Connections>
;#Include <Jira>
;#Include <Confluence>
;#Include <Blogger>
LastCompiled = 20230111205928
; AutoExecute Section must be on the top of the script
#Warn All, OutputDebug
#Warn LocalSameAsGlobal, off
GroupAdd, Explorer, ahk_class CabinetWClass
GroupAdd, Explorer, ahk_class ExploreWClass
GroupAdd, Explorer, ahk_exe FreeCommander.exe
GroupAdd, Explorer, ahk_exe TOTALCMD.EXE
GroupAdd, OpenLinks, ahk_exe outlook.exe
GroupAdd, OpenLinks, ahk_exe powerpoint.exe
GroupAdd, OpenLinks, ahk_exe onenote.exe
GroupAdd, OpenLinks, ahk_exe word.exe
GroupAdd, OpenLinks, ahk_exe winword.exe
GroupAdd, OpenLinks, ahk_exe Teams.exe
GroupAdd, OpenLinks, ahk_exe ms-teams.exe
GroupAdd, OpenLinks, ahk_exe lync.exe ; Skype
GroupAdd, OpenLinks, ahk_exe chrome.exe
GroupAdd, OpenLinks, ahk_exe EXCEL.exe
GroupAdd, MSOffice, ahk_exe outlook.exe
GroupAdd, MSOffice, ahk_exe powerpoint.exe
GroupAdd, MSOffice, ahk_exe POWERPNT.exe
GroupAdd, MSOffice, ahk_exe onenote.exe
GroupAdd, MSOffice, ahk_exe word.exe
GroupAdd, MSOffice, ahk_exe WINWORD.exe
GroupAdd, MSOffice, ahk_exe excel.exe
GroupAdd, MSOffice, ahk_exe teams.exe
GroupAdd, MSOffice, ahk_exe lync.exe
GroupAdd, NoIntelliPasteIns, ahk_exe XMind.exe
GroupAdd, NoIntelliPasteIns, ahk_exe freemind.exe
#SingleInstance force ; for running from editor - avoid warning another instance is running
SetTitleMatchMode, 2 ; partial match
Config := PowerTools_GetConfig() ; check also if defined
PowerTools_ConnectionsRootUrl := PowerTools_RegRead("ConnectionsRootUrl")
SubMenuSettings := PowerTools_MenuTray()
Menu,Tray,Insert,Settings,PowerTools Bundler, PowerTools_RunBundler
; -------------------------------------------------------------------------------------------------------------------
; SETTINGS
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
}
; IntelliPaste Hotkey setting
Menu, SubMenuSettingsIntelliPaste, Add, &Hotkey, IntelliPaste_HotkeySet
Menu, SubMenuSettingsIntelliPaste, Add, &Update SharePoint Sync Ini, SharePoint_UpdateSync
Menu, SubMenuSettingsIntelliPaste, Add, &Refresh Teams List and SPSync.ini, IntelliPaste_Refresh
Menu, SubMenuSettingsIntelliPaste, Add, Help, IntelliPaste_Help
Menu, SubMenuSettings, Add, IntelliPaste, :SubMenuSettingsIntelliPaste
Menu, SubMenuSettings, Add, Set Jira UserName, SetSetting
Menu, SubMenuSettings, Add, Set Jira RootUrl, SetSetting
Menu, SubMenuSettings, Add, Set Phone Number, SetSetting
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
; -------------------------------------------------------------------------------------------------------------------
; Setting - IntelliPasteHotkey
RegRead, IntelliPasteHotkey, HKEY_CURRENT_USER\Software\PowerTools, IntelliPasteHotkey
If ErrorLevel { ; regkey not set-> take default
IntelliPasteHotkey = Insert
PowerTools_RegWrite("IntelliPasteHotkey",IntelliPasteHotkey)
}
If (IntelliPasteHotkey == "Insert") {
Hotkey, IfWinNotActive, ahk_group NoIntelliPasteIns
Hotkey, %IntelliPasteHotkey%, IntelliPaste, On
Hotkey, IfWinNotActive,
} Else
Hotkey, %IntelliPasteHotkey%, IntelliPaste, On
; -------------------------------------------------------------------------------------------------------------------
; Tooltip
If !a_iscompiled
FileGetTime, LastMod , %A_ScriptFullPath%
Else
LastMod := LastCompiled
FormatTime LastMod, %LastMod% D1 R
sTooltip = NWS PowerTool %LastMod%.`nClick on icon to access Help and Settings.
Menu, Tray, Tip, %sTooltip%
If (SettingNotificationAtStartup)
TrayTip NWS PowerTool is running! , Click on icon to access Help and Settings.
; -------------------------------------------------------------------------------------------------------------------
; Add Custom Menus to MenuTray
Menu,Tray,NoStandard
If FileExist("Lib/Conti.ahk") & (Config = "Conti") {
Menu,SubMenuFavs,Add, Open NWS Search, Conti_NWSSearch
Menu,SubMenuFavs,Add, Create Ticket (ESS), SysTrayCreateTicket
Menu,SubMenuFavs,Add, KSSE, Conti_KSSE
}
Menu, SubMenuFavs,Add, Cursor Highlighter, PowerTools_CursorHighlighter
Menu, Tray, Add, Tools, :SubMenuFavs
Menu, Tray,Add, Toggle AlwaysOnTop (Ctrl+Shift+Space), SysTrayToggleAlwaysOnTop
Menu, Tray,Add, Toggle Title Bar, SysTrayToggleTitleBar
Menu, SubMenuODB, Add, Open Permissions Settings,ODBOpenPermissions
Menu, SubMenuODB, Add, Open Document Library in Classic View,ODBOpenDocLibClassic
Menu, Tray, Add, OneDrive, :SubMenuODB
Menu, SubMenuODM, Add, ODM Set Path, ODMSetPath
Menu, SubMenuODM, Add, ODM Edit, ODMEdit
Menu, SubMenuODM, Add, ODM Run, ODMRun
Menu, SubMenuODM, Add, ODM AutoStart, MenuCb_ToggleODMAutoStart
RegRead, ODMAutoStart, HKEY_CURRENT_USER\Software\PowerTools, ODMAutoStart
If (ODMAutoStart)
Menu,SubMenuODM,Check, ODM AutoStart
Else
Menu,SubMenuODM,UnCheck, ODM AutoStart
Menu, Tray, Add, OneDrive Mapper, :SubMenuODM
If (ODMAutoStart) {
RegRead, ODMPath, HKEY_CURRENT_USER\Software\PowerTools, ODMPath
If ODMPath {
RunWait, PowerShell.exe -ExecutionPolicy Bypass -Command %ODMPath% ,, Hide
} Else {
TrayTipAutoHide("ODM Wrong Setup","ODM AutoStart is set but .ps1 file is not set.")
}
}
Menu, Tray,Add ; Separator
Menu, Tray,Standard
; -------------------------------------------------------------------------------------------------------------------
; NWS Menu (Shown with Win+F1 hotkey in Browser)
Menu, NWSMenu, add, (Browser) Intelli &Copy current Url (Ctrl+Shift+C), IntelliCopyActiveUrl
Menu, NWSMenu, add, (Browser) Share by E&mail current Url (Ctrl+Shift+M), EmailShareActiveUrl
Menu, NWSMenu, add, (Browser) Share Url to Teams, TeamsShareActiveUrl
Menu, NWSMenu, add, (Browser) Quick &Search (Win+F), QuickSearch
If FileExist("Lib/Conti.ahk") and (Config = "Conti")
Menu, NWSMenu, add, (Browser) Create IT &Ticket, Conti_CreateTicket
Menu, NWSMenu, Add, Open Issue (Ctrl+Shift+I), OpenIssue
; -------------------------------------------------------------------------------------------------------------------
; EDIT : SCRIPT PARAMETERS
DefExplorerExe := "explorer.exe" ;*[NWS]
IfNotExist, %DefExplorerExe%
DefExplorerExe := "explorer.exe"
; Start VPN (only for Conti config)
If FileExist("Lib/Conti.ahk") and (Config = "Conti") {
If ! (Login_IsNet("Conti"))
Login_VPNConnect()
}
return
; ####################################################################
; Hotkeys
; -------------------------------------------------------------------------------------------------------------------
^+Space:: ;<--- Always on Top
WinSet, AlwaysOnTop, Toggle, A
return
;================================================================================================
; CapsLock processing. Must double tap CapsLock to toggle CapsLock mode on or off.
; https://www.howtogeek.com/446418/how-to-use-caps-lock-as-a-modifier-key-on-windows/
;================================================================================================
; Must double tap CapsLock to toggle CapsLock mode on or off.
CapsLock:: ; <--- Must double tap CapsLock to toggle CapsLock mode on or off.
KeyWait, CapsLock ; Wait forever until Capslock is released.
KeyWait, CapsLock, D T0.2 ; ErrorLevel = 1 if CapsLock not down within 0.2 seconds.
if ((ErrorLevel = 0) && (A_PriorKey = "CapsLock") ) ; Is a double tap on CapsLock?
{
SetCapsLockState, % GetKeyState("CapsLock","T") ? "Off" : "On" ; Toggle the state of CapsLock LED
}
return
;================================================================================================
; Hotkeys with CapsLock modifier. See https://autohotkey.com/docs/Hotkeys.htm#combo
;================================================================================================
#If (PowerTools_ConnectionsRootUrl != "")
CapsLock & c:: ; <--- Connections Global Search
sSelection:= Clip_GetSelection()
Run, https://%PowerTools_ConnectionsRootUrl%/search/web/search?query=%sSelection% ; Launch with contents of clipboard
Return
#If
CapsLock & d:: ; <--- Get DEFINITION of selected word.
sSelection:= Clip_GetSelection()
Run, http://www.google.com/search?q=define+%sSelection% ; Launch with contents of clipboard
Return
CapsLock & s:: ; <--- Search in Scaledagile.com.
sSelection:= Clip_GetSelection()
Run, "https://www.google.com/search?q=site:https://www.scaledagileframework.com %sSelection%" ; Launch with contents of clipboard
Return
CapsLock & b:: ; <--- Bing search.
sSelection:= Clip_GetSelection()
If RegExMatch(sSelection,"(.*), (.*) <(.*)>",sMatch) ; From Outlook contact
sSelection = %sMatch2% %sMatch1%#,Person ; Transform Firstname Lastname
Run, https://www.bing.com/search?q=%sSelection% ; Launch with contents of clipboard
Return
CapsLock & g:: ; <--- GOOGLE the selected text.
sSelection:= Clip_GetSelection()
Run, "https://www.google.com/search?q=%sSelection%" ; Launch with contents of clipboard
Return
;CapsLock & t:: ; <--- Do THESAURUS of selected text
;sSelection:= Clip_GetSelection()
;Run http://www.thesaurus.com/browse/%sSelection% ; Launch with contents of clipboard
;Return
CapsLock & w:: ; <--- Do WIKIPEDIA of selected text
sSelection:= Clip_GetSelection()
Run, https://en.wikipedia.org/wiki/%sSelection% ; Launch with contents of clipboard
Return
#If FileExist("Lib/Conti.ahk") & (Config = "Conti")
CapsLock & n:: ; <--- Open NWS Search or trigger NWS Search with selected text
FunStr = Conti_NWSSearch
%FunStr%()
return
#If
CapsLock & y:: ; <--- YouTube search of selected text
sSelection:= Clip_GetSelection()
Run, https://www.youtube.com/results?search_query=%sSelection% ; Launch with contents of clipboard
return
; -------------------------------------------------------------------------------------------------------------------
; All Applications
; -------------------------------------------------------------------------------------------------------------------
; -------------------------------------------------------------------------------------------------------------------
; Ctrl+F12
^F12:: ; <--- Paste clean url with url decoded
PasteCleanUrl()
return
; -------------------------------------------------------------------------------------------------------------------
; Ctrl+Ins: paste clean url without uridecode - unbroken link
; useful to paste unbroken link e.g. in Connections comments
^Ins:: ; <--- Paste Clean Url
PasteCleanUrl(true)
return
; Alt+Ins or Ctrl+Alt+V: Paste Clipboard in plain text/ removing rich-text formatting like links
; http://stackoverflow.com/a/132826/2043349
; https://lifehacker.com/better-paste-takes-the-annoyance-out-of-pasting-formatt-5388814
^!v::
!Ins:: ; <--- Paste Clipboard without formatting (Plain Text)
Clip_Paste(Clipboard)
return
; -------------------------------------------------------------------------------------------------------------------
#IfWinActive, ahk_group OpenLinks
; Open in Default Browser (incl. Office applications) - see OpenLink function
; Shift Mouse click OpenLink
+LButton:: ;
Clip_All := ClipboardAll ; Save the entire clipboard to a variable
Clipboard = ; Empty the clipboard to allow ClipWait work
Send {Shift Up} ; Release shift because of Conflict to open context menu if pressed down
SendEvent {RButton} ;Click Right does not work in Outlook embedded tables
sleep, 200 ;(wait in ms) give time for the menu to popup
If WinActive("ahk_exe onenote.exe")
SendInput i ; Copy Link
Else If WinActive("ahk_exe " . Teams_GetExeName()) ; ByPass SafeLink https://tdalon.blogspot.com/2023/01/teams-bypass-safelink.html
SendInput {Up} {Enter}
Else If WinActive("ahk_exe chrome.exe")
SendInput e ; Send the underlined key https://superuser.com/questions/1721702/how-to-show-the-underlines-for-navigation-key-hotkey-in-context-menu-when-ri that copies the link from the right click menu. see https://productforums.google.com/forum/#!topic/chrome/CPi4EmhqHPE
; See also https://stackoverflow.com/questions/62707998/chrome-windows10-right-click-context-menu-option-underline-on-key-missing Press Alt+Shift before Right-Click
Else If WinActive("ahk_exe EXCEL.exe") {
SendInput H
sleep 500
Send ^c
Send {Esc}
} Else
SendInput c ; Copy Link
ClipWait, 2
sUrl := Clipboard
If sUrl { ; Not empty
;sUrl := IntelliPaste_CleanUrl(sUrl) ; convert e.g. teams links to SP links
;Run %sUrl% ; Handled by BrowserTamer -> blocked by IT
PowerTools_OpenLink(sUrl)
} Else {
Send {LButton}
}
Clipboard := Clip_All ; Restore the original clipboard
return
; -------------------------------------------------------------------------------------------------------------------
#If WinActive("ahk_exe Code - Insiders.exe") || WinActive("ahk_exe Code.exe")
;Alt+C
!c:: ; <--- Toggle Block comment Uncomment. Block need to be selected
ClipBackup:= ClipboardAll
sSelection := Clip_GetSelection(False)
If !sSelection { ; no sSelection
Clip_Restore(ClipBackup)
Return
}
If RegExMatch(sSelection,"s)^/\*.*\*/$") {
sNew := SubStr(sSelection, InStr(sSelection,"`n") + 1) ; remove first line
sNew := SubStr(sNew, 1,InStr(sNew, "`r" , , -1) -1) ; remove last line
} Else {
sNew = /*`n%sSelection%`n*/
}
Clip_Paste(sNew)
Clip_Restore(ClipBackup)
return
; -------------------------------------------------------------------------------------------------------------------
#If WinActive(".ahk")
; Alt+h
!h:: ; <--- AHK Open Help command
kw := Clip_GrabWord()
AHK_Help(kw)
;Run,% "https://www.autohotkey.com/docs/commands/" cmd ".htm"
Return
; -------------------------------------------------------------------------------------------------------------------
; BROWSER Group
; -------------------------------------------------------------------------------------------------------------------
#If Browser_WinActive()
/*
; Ctrl + Alt + V - remove quotes for MySuccess copy/paste of goals from Excel
#IfWinActive,ahk_group Browser
^!v::
ClipSaved := ClipboardAll
sUrl := clipboard
sUrl := StrReplace(sUrl,"""","")
;MsgBox Clean url:`n%sUrl%
clipboard = ; Empty the clipboard
Clipboard := sUrl
ClipWait, 0.5
Send ^v
Sleep 100 ; pause necessary because of lag in browser (no problem in Notepad e.g.)- next command restore clipboard runs asynchron before paste
; https://autohotkey.com/board/topic/37029-good-practices-with-clipboard/#entry233156
Clipboard := ClipSaved ; restore clipboard
return
*/
; Win+F
#f:: ; <--- [Browser] Run Quick Search (Connections, Confluence, Jira, Google)
QuickSearch()
return
; Ctrl+E - like Explorer or Edit - from Browser
; Do not use Alt key because of issue with IE
^e:: ; <--- [Browser] Edit Connections or Open SharePoint in File Explorer
;!e:: ; Alt+E because Ctrl+E is used and can not be overwritten with Windows 10 and IE/Edge Browser Universal App
sUrl := Browser_GetUrl()
If Connections_IsUrl(sUrl) {
Connections_Edit(sUrl)
return
} Else If Blogger_IsUrl(sUrl) {
Blogger_Edit(sUrl)
return
} Else If SharePoint_IsUrl(sUrl) { ; SharePoint
newurl:= SharePoint_CleanUrl(sUrl) ; returns wihout ending /
; For o365 SharePoint check if file is synced in SPsync.ini
If SharePoint_IsSPWithSync(newurl) { ; mspe can also offers Sync
sFile := SharePoint_Url2Sync(sUrl)
If (sFile=""){
TrayTipAutoHide("NWS PowerTool","SharePoint is not Sync'ed or OneDrive SPSync.ini File is not properly configured!",3,0x3)
Run "%sIniFile%"
return
}
Run %DefExplorerExe% "%sFile%"
} Else { ; SharePoints without Sync-> use Dav access
newurl:=StrReplace(newurl,"https:","")
newurl:=StrReplace(newurl,"+"," ") ; strange issue with blank converted to +
newurl:=StrReplace(newurl,"/","\")
newurl:= RegExReplace(newurl,"https?//[^/]*","$0@ssl\DavWWWroot") ; without @ssl it takes too long to open
Run %DefExplorerExe% "%newurl%"
}
} Else {
TrayTipAutoHide("NWS PowerTool",sUrl . " did not match a Connections, SharePoint or Blogger url!",,0x2)
}
return
#F1:: ; <--- [Browser] Open NWS PowerTool Menu
; Win+F1
Menu, NWSMenu, Show
return
; -------------------------------------------------------------------------------------------------------------------
; IntelliCopyActiveURL Ctrl+Shift+C
#If Browser_WinActive()
^+c:: ; <--- [Browser] Intelli Copy Active Url
IntelliCopyActiveUrl:
If GetKeyState("Ctrl") and !GetKeyState("Shift") {
Run, "https://tdalon.blogspot.com/2023/02/intellicopy-browser-url.html"
return
}
sLink := Browser_GetUrl()
If ErrorLevel {
MsgBox 0x1010, Error, No url could be copied!
return
}
sLink := IntelliPaste_CleanUrl(sLink)
WinGetActiveTitle, linktext
; Remove trailing - containing program e.g. - Google Chrome
StringGetPos,pos,linktext,%A_space%-,R
if (pos >=0)
linktext := SubStr(linktext,1,pos)
If FileExist("Lib/Connections.ahk") {
FunStr := "Connections_IsUrl"
If %FunStr%(sLink) {
FunStr := "Connections_Link2Text"
linktext := %FunStr%(sUrl)
}
}
sHtml =<a href="%sLink%">%linktext%</a>
Clip_SetHtml(sHtml,sLink)
TrayTipAutoHide("NWS PowerTool","Link was copied to the clipboard!")
return
; -------------------------------------------------------------------------------------------------------------------
; IntelliSharebyEmailActiveURL Ctrl+Shift+M
#If Browser_WinActive()
^+m:: ; <--- [Browser] Share by eMail active url
EmailShareActiveUrl:
If GetKeyState("Ctrl") and !GetKeyState("Shift") {
Run, "https://tdalon.blogspot.com/2023/10/share-url-by-email.html"
return
}
sLink := Browser_GetUrl()
If ErrorLevel {
MsgBox 0x1010, Error, No url could be copied!
return
}
AppList = Jira,Confluence,Connections
Loop, Parse, AppList, `,
{
If FileExist("Lib/" . A_LoopField . ".ahk") {
FunStr := A_LoopField . "_IsUrl"
If %FunStr%(sLink) {
FunStr := A_LoopField . "_CleanLink"
link := %FunStr%(sUrl)
sLink := link[1]
linktext := link[2]
Goto, WriteEmail
}
}
}
sLink := IntelliPaste_CleanUrl(sLink)
WinGetActiveTitle, linktext
; Remove trailing - containing program e.g. - Google Chrome
StringGetPos,pos,linktext,%A_space%-,R
if (pos != -1)
linktext := SubStr(linktext,1,pos)
WriteEmail:
sHTMLBody = Hello<br>I thought you might be interested in this post: <a href="%sLink%">%linktext%</a>.<br>
; 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.Display ;Make email visible
return
; -------------------------------------------------------------------------------------------------------------------
; #CHROME BROWSER
; -------------------------------------------------------------------------------------------------------------------
#IfWinActive ahk_exe chrome.exe
;https://autohotkey.com/board/topic/84792-opening-a-link-in-non-default-browser/
; Ctrl+Right mouse button
^RButton:: ; <--- [Chrome] Open link in File Explorer
SavedClipboard := ClipboardAll ; Save the entire clipboard to a variable
Clipboard := "" ; Empty the clipboard to allow ClipWait work
Click Right ; Click Right mouse button
sleep, 100 ;(wait in ms) give time for the menu to popup
SendInput e ; Send the underlined key that copies the link from the right click menu. see https://productforums.google.com/forum/#!topic/chrome/CPi4EmhqHPE
ClipWait, 2
sUrl := Clipboard
If !sUrl
Exit
If SharePoint_IsUrl(sUrl) {
newurl:=SharePoint_CleanUrl(sUrl)
newurl:=StrReplace(newurl,"https:","")
newurl:=StrReplace(newurl,"+"," ") ; strange issue with blank converted to +
newurl:=StrReplace(newurl,"/","\")
newurl:= RegExReplace(newurl,"https?//[^/]*","$0@ssl\DavWWWroot") ; without @ssl it takes too long to open
Run %DefExplorerExe% "%newurl%"
}
Clipboard := SavedClipboard ; Restore the original clipboard
return
; -------------------------------------------------------------------------------------------------------------------
; EXPLORER Group
; -------------------------------------------------------------------------------------------------------------------
#ifWinActive,ahk_group Explorer ; Set hotkeys to work in explorer only
; Open file With Notepad++ from Explorer using Alt+N hotkey
; https://autohotkey.com/board/topic/77665-open-files-with-portable-notepad/
; -------------------------------------------------------------------------------------------------------------------
; Alt+N
!n:: ; <--- [Explorer] Open file in Notepad++
ClipSaved := ClipboardAll
Clipboard := ""
SendInput ^c
ClipWait, 0.5
file := Clipboard
Clipboard := ClipSaved
Run, notepad++.exe "%file%"
return
; -------------------------------------------------------------------------------------------------------------------
; Override Delete key for Sync location
/*
$Del:: ; <--- [Explorer] Safeguard Delete if in ODB Sync location
sFile := Explorer_GetSelection()
; if no file selected in File Explorer
If (!sFile) ; file empty
return
EnvGet, sOneDriveDir , onedrive
sOneDriveDir := StrReplace(sOneDriveDir,"OneDrive - ","")
If InStr(sFile,sOneDriveDir . "\") {
MsgBox 0x14, Delete?,Are you sure you want to delete in your Sync location?`nIt might also delete the file in the SharePoint / not only locally for you, if sync is active.
IfMsgBox, No
return
}
Send {Delete}
return
*/
; -------------------------------------------------------------------------------------------------------------------
; Ctrl+E Open SharePoint File from mapped Document Library or Sync location in Default Browser
; Calls: GetFileLink, GetExplorerSelection
^e:: ; <--- [Explorer] Open SharePoint file selection in IE Browser
sFile := Explorer_GetSelection()
; if no file selected in File Explorer
If !sFile ; empty
{
MsgBox "You need to select a file!"
return
}
; For multi-section take the last one
sFile := RegExReplace(sFile,"`n.*","")
sFile := GetFileLink(sFile)
If (!sFile) ; file empty
return
SplitPath, sFile, OutFileName, OutDir
If InStr(OutFileName,".") ; then a file is selected (Last part in Path containing "." for file extension)
Run, "%OutDir%" ; Open parent directory
Else
Run, "%sFile%"
return
; -------------------------------------------------------------------------------------------------------------------
; Ctrl+O
; Calls: GetFileLink, Explorer_GetSelection
^o:: ; <--- [Explorer] Open file
sFiles := Explorer_GetSelection()
; if no file selected in File Explorer
If sFiles =
{
MsgBox "You need to select a file!"
return
}
Loop, parse, sFiles, `n, `r
{
sFile := A_LoopField
If InStr(sFile,".xlsx") or InStr(sFile,".docx") or InStr(sFile,".pptx") or InStr(sFile,".xlsm") or InStr(sFile,".docm") or InStr(sFile,".pptm") {
sFile := GetFileLink(sFile)
Run, iexplore.exe "%sFile%" ; BUG: Edge can not open file links
} Else
Run, Open "%sFile%"
}
return
; -------------------------------------------------------------------------------------------------------------------
; Ctrl+K
^k:: ; <--- [Explorer] Copy File Link (OneDrive)
Send +{F10} ; Shift+F10
Send s
Send {Enter}
Sleep 2000 ; Time to load the UI
Send {Tab 3}
Send {Enter}
Send {Esc}
return
; Open Issue Ctrl+Shift+I
^+i:: ; <--- Open Issue (Jira, ServiceDesk)
OpenIssue:
If GetKeyState("Ctrl") and !GetKeyState("Shift") {
Run, "" ;TODO add link to documentation
return
}
If WinActive("ahk_exe EXCEL.EXE") {
sKey := Jira_Excel_GetIssueKeys()
If (sKey="")
return
Jira_OpenIssues(sKey)
} Else {
Jira_OpenIssueSelection()
}
return
; ######################################################################
NotifyTrayClick_202: ; Left click (Button up)
Menu_Show(MenuGetHandle("Tray"), False, Menu_TrayParams()*)
Return
NotifyTrayClick_205: ; Right click (Button up)
SendInput, !{Esc} ; for call from system tray - get active window
Menu, NWSMenu, Show
Return
SysTrayToggleAlwaysOnTop:
SendInput, !{Esc}
WinSet, AlwaysOnTop, Toggle, A
;Tooltip("Toggle Active Window AlwaysOnTop",1000)
return
SysTrayToggleTitleBar:
SendInput, !{Esc}
WinSet, Style, ^0xC00000, A ; toggle title bar
return
; -------------------------------------------------------------------------------------------------------------------
; -------------------------------------------------------------------------------------------------------------------
; FUNCTIONS
; -------------------------------------------------------------------------------------------------------------------
; -------------------------------------------------------------------------------------------------------------------
;IsIELink(url)
; true if link shall be opened with Internet Explorer rather than another browser e.g. Chrome because of incompatibility
IsIELink(sUrl){
If InStr(sUrl,"file://") || InStr(sUrl,"/pkit/") || InStr(sUrl,"/BlobIT/") || InStr(sUrl,"/openscapeuc/dial/")
return true
Else
return false
}
; -------------------------------------------------------------------------------------------------------------------
PasteCleanUrl(encode:= False){
; encode: True/False
; calls: CleanUrl
; called by Hotkey Ctrl+Ins [decode=false] and Ctrl+F12 [decode=true]
ClipSaved := ClipboardAll
sUrl := clipboard
sUrl := GetFileLink(sUrl)
sUrl := IntelliPaste_CleanUrl(sUrl)
If (encode) {
sUrl := uriEncode(sUrl)
sUrl := StrReplace(sUrl,":","%3A")
sUrl := StrReplace(sUrl,"https%3A","https:")
sUrl := StrReplace(sUrl,"http%3A","http:")
}
;MsgBox Clean url:`n%sUrl%
;sendInput % sUrl
Clip_Paste(sUrl)
return
}
; ----------------------------------------------------------------------
QuickSearch(){
If GetKeyState("Ctrl") and !GetKeyState("Shift") {
sUrl := "https://tdalon.github.io/ahk/QuickSearch"
Run, "%sUrl%"
return
}
sUrl := Browser_GetUrl()
If !sUrl { ; empty
MsgBox Cannot get URL ; DBG
return
}
; Make Libraries optional
/*
If Goodreads_IsUrl(sUrl) {
Goodreads_Search(sUrl)
return
}
*/
QuickSearches := "Confluence,Jira,Connections,Blogger,Goodreads,Stackoverflow"
Loop, parse, QuickSearches, `,
{
If FileExist("Lib/" . A_LoopField . ".ahk") {
FunStr := A_LoopField . "_IsUrl"
If %FunStr%(sUrl) {
FunStr := A_LoopField . "_Search"
%FunStr%(sUrl)
return
}
}
}
If RegExMatch(sUrl,"youtube\.com/(?:c|channel)/") { ; YouTube Channel Search
; https://www.youtube.com/c/KevinStratvert/search?query=remove%20background
;https://www.youtube.com/channel/UCfJT_eYDTmDE-ovKaxVE1ig/search?query=background
sPat = youtube\.com/(?:c|channel)/([^/]*)/search\?query=(.*)
sDefSearch =
If RegExMatch(sUrl,sPat, sMatch) {
sDefSearch := StrReplace(sMatch2,"%20"," ")
sDefSearch := StrReplace(sDefSearch,"+"," ")
sChannelName := sMatch1
} Else {
sPat = youtube\.com/(?:c|channel)/([^/]*)
RegExMatch(sUrl,sPat, sMatch)
sChannelName := sMatch1
}
InputBox, sSearch , YouTube Channel Search, Enter search string:,,640,125,,,,, %sDefSearch%
if ErrorLevel
return
sSearch := Trim(sSearch)
sSearchUrl = https://www.youtube.com/channel/%sChannelName%/search?query=%sSearch%
SendInput ^t^l ; close current search window
Clip_Paste(sSearchUrl)
SendInput {Enter}
SendInput ^{Tab}
Sleep 500
SendInput ^w
} Else If InStr(sUrl,"google.com/search?q=") and !InStr(sUrl,"site:") { ; simple google search
sPat = google.com/search\?q=([^&]*)
sPat := StrReplace(sPat,".","\.")
RegExMatch(sUrl,sPat, sMatch)
sSearch := StrReplace(sMatch1,"%20"," ")
sSearch := StrReplace(sSearch,"+"," ")
InputBox, sSearch , Google Search, Enter search string:,,640,125,,,,, %sSearch%
if ErrorLevel
return
sSearch := Trim(sSearch)
sSearchUrl = https://www.google.com/search?q=%sSearch%
SendInput ^t^l
Clip_Paste(sSearchUrl)
SendInput {Enter}
; close previous search window
SendInput ^{Tab}
Sleep 500
SendInput ^w
} Else {
sPat = google.com/search\?q=site:([^`%]*)`%20 ; Chrome strips https://www. for google
sPat := StrReplace(sPat,".","\.")
If RegExMatch(sUrl,sPat . "(.*)", sMatch) { ; https://www.google.com/search?q=site:https://scaledagileframework.com%20pipeline
sDefSearch := StrReplace(sMatch2,"%20"," ")
sRootUrl := sMatch1
;SendInput ^w ; close current search window
} Else {
RegExMatch(sUrl,"https?://[^/]*",sRootUrl)
}
InputBox, sSearch , Google Site Search, Enter search string:,,640,125,,,,, %sDefSearch%
if ErrorLevel
return
sSearch := Trim(sSearch)
sSearchUrl = https://www.google.com/search?q=site:%sRootUrl% %sSearch%
SendInput ^t^l
Clip_Paste(sSearchUrl)
SendInput {Enter}
; close previous search window
SendInput ^{Tab}
Sleep 500
SendInput ^w
}
} ; eofun
; ----------------------------------------------------------------------
; ----------------------------------------------------------------------
SetSetting(ItemName){
If GetKeyState("Ctrl") {
sUrl := "https://tdalon.github.io/ahk/NWS-PowerTool"
Run, "%sUrl%"
return
}
PowerTools_SetSetting(ItemName)
}
; ----------------------------------------------------------------------
ODBOpenPermissions(){
If GetKeyState("Ctrl") {
sUrl := "https://connectionsroot/blogs/tdalon/entry/onedrive_open_persmissions_settings_powertool"
Run, "%sUrl%"
return
}
OfficeUid := People_GetMyOUid()
TenantName := PowerTools_GetSetting("TenantName")
Domain := People_GetDomain()
Domain := StrReplace(Domain,".","_")
Run https://%TenantName%-my.sharepoint.com/personal/%OfficeUid%_%Domain%/_layouts/15/user.aspx
}
; ----------------------------------------------------------------------
ODBOpenDocLibClassic(){
If GetKeyState("Ctrl") {
sUrl := "https://connectionsroot/blogs/tdalon/entry/onedrive_alert#Shortcut_/_PowerTool_way"
Run, "%sUrl%"
return
}
OfficeUid := People_GetMyOUid()
Domain := People_GetDomain()
Domain := StrReplace(Domain,".","_")
TenantName := PowerTools_GetSetting("TenantName")
sUrl := "https://%TenantName%-my.sharepoint.com/personal/" . OfficeUid . "_%Domain%/Documents/Forms/All.aspx?ShowRibbon=true&InitialTabId=Ribbon%2ELibrary&VisibilityContext=WSSTabPersistence"
Run, "%sUrl%"
}
; ----------------------------------------------------------------------
TeamsShareActiveUrl:
If GetKeyState("Ctrl") and !GetKeyState("Shift") {
Run, "https://tdalon.blogspot.com/share-to-teams"
return
}
sLink := Browser_GetUrl()
sLink := IntelliPaste_CleanUrl(sLink)
sLink = https://teams.microsoft.com/share?href=%sLink%
Run %sLink%
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
; ----------------------------------------------------------------------
MenuCb_ToggleODMAutoStart(ItemName, ItemPos, MenuName){
If GetKeyState("Ctrl") {
sUrl := "https://connectionsroot/blogs/tdalon/entry/OneDrive_Mapper"
Run, "%sUrl%"
return
}
RegRead, ODMAutoStart, HKEY_CURRENT_USER\Software\PowerTools, ODMAutoStart
ODMAutoStart := !ODMAutoStart
If (ODMAutoStart) {
RegRead, ODMPath, HKEY_CURRENT_USER\Software\PowerTools, ODMPath
If !ODMPath {
ODMPath := ODMSetPath()
If ODMPath ; If no path entered cancel
return
}
Menu,%MenuName%,Check, %ItemName%
TrayTipAutoHide("OneDrive Mapper","OneDrive Mapper will auto-start with this script.")
} Else {
Menu,%MenuName%,UnCheck, %ItemName%
TrayTipAutoHide("OneDrive Mapper","OneDrive Mapper auto-start was switched OFF.")
}
PowerTools_RegWrite("ODMAutoStart",ODMAutoStart)
}
ODMSetPath(){
If GetKeyState("Ctrl") {
sUrl := "https://connectionsroot/blogs/tdalon/entry/OneDrive_Mapper"
Run, "%sUrl%"
return
}
FileSelectFile, ODMPath , 1, OneDriveMapper.ps1, Browse for your OneDriveMapper.ps1 location
If (ODMPath = "") or !InStr(ODMPath,"OneDriveMapper.ps1") {
TrayTipAutoHide("OneDrive Mapper Setup","OneDriveMapper.ps1 wasn't selected!")
ODMPath =
} Else {
PowerTools_RegWrite("ODMPath",ODMPath)
}
return ODMPath
}
ODMEdit(){
If GetKeyState("Ctrl") {
sUrl := "https://connectionsroot/blogs/tdalon/entry/OneDrive_Mapper"
Run, "%sUrl%"
return
}
RegRead, ODMPath, HKEY_CURRENT_USER\Software\PowerTools, ODMPath
If !ODMPath {
TrayTipAutoHide("OneDrive Mapper Setup","OneDriveMapper.ps1 wasn't selected! Set ODM Path.")
return
}
sCmd = Edit "%ODMPath%"
Run %sCmd%
}
ODMRun(){