/
FocusAssist.ahk
86 lines (57 loc) · 1.75 KB
/
FocusAssist.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
; See documentation https://tdalon.blogspot.com/2023/09/autohotkey-focus-assist.html
LastCompiled =
#SingleInstance force ; for running from editor
#Include <UIA_Interface>
SetTitleMatchMode, 1 ; start with
If (A_Args.Length() = 0) {
;RefreshProfiles()
PowerTools_MenuTray()
; Tooltip
If !a_iscompiled
FileGetTime, LastMod , %A_ScriptFullPath%
Else
LastMod := LastCompiled
FormatTime LastMod, %LastMod% D1 R
sTooltip = FocusAssist %LastMod%`nRight-Click on icon to access help/support.
Menu, Tray, Tip, %sTooltip%
return
} ; end icon tray
If (A_Args.Length() > 0)
FocusAssist(A_Args[1])
ExitApp
/*
#f::
; overwrite feedback hub
FocusAssist("+")
return
#o::
FocusAssist("-")
return
*/
; ################## FUNCTIONS ###########################
; ------------------------------------------------------------------------------
FocusAssist(sInput){
; Open Focus Assist Settings
; Win+R 'Focus Assist'
; Alternative open url ms-settings:quiethours
; https://support.microsoft.com/en-us/windows/make-it-easier-to-focus-on-tasks-0d259fd9-e9d0-702c-c027-007f0e78ea
Run, ms-settings:quiethours
; Wait for WinTitle=Settings
WinWaitActive,Settings
UIA := UIA_Interface()
WinId := WinActive("A")
UIAEl := UIA.ElementFromHandle(WinId)
Switch sInput
{
Case "f","-": ; Off
Filter := "AutomationId=Microsoft.QuietHoursProfile.Unrestricted_Button"
Case "p","+": ; Priority Only
Filter := "AutomationId=Microsoft.QuietHoursProfile.PriorityOnly_Button"
Case "a": ; Alarm Only
Filter := "AutomationId=Microsoft.QuietHoursProfile.AlarmsOnly_Button"
}
Btn := UIAEl.WaitElementExist(Filter)
Btn.Click()
Send !{f4} ; Close settings window
} ; eofun
; ------------------------------------------------------------