-
Notifications
You must be signed in to change notification settings - Fork 0
/
Window Wizard.ahk
209 lines (187 loc) · 4.81 KB
/
Window Wizard.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
#SingleInstance, force
Menu, Tray, Icon, images\WoosterGraphic.ico
Menu, Tray, Tip, WTS: Window Wizard
SetTitleMatchMode 2
DetectHiddenWindows, On
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Initialization ;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define INI file location
pathINI = % A_AppData "\Wooster Technical Solutions\WoosterTech.ini"
; Section of INI file for 3CX
iniSection = WindowWizard
; Initialize iniProps
iniProps := {}
; Properties from INI file with their defaults
iniProps["SlackHide"] := true
iniProps["OutlookHide"] := true
iniProps["TeamsHide"] := true
iniProps["3cxHide"] := false
iniProps["8by8Hide"] := true
iniProps["YourPhoneHide"] := true
iniProps["outlookKey"] := "F10"
iniProps["slackKey"] := "F8"
iniProps["teamsKey"] := "F9"
iniProps["8by8Key"] := "F11"
iniProps["YourPhoneKey"] := "F7"
iniProps["teamsCommand"] := """""C:\Users\" A_UserName "\AppData\Local\Microsoft\Teams\Update.exe"" --processStart ""Teams.exe"""""
iniProps["slackCommand"] := "Slack.exe"
iniProps["slackWinTitle"] := "Slack |"
iniProps["8by8WinTitle"] := "8x8 Work"
iniProps["8by8Command"] := """""C:\Users\" A_UserName "\AppData\Local\8x8-Work\8x8 Work.exe"""
iniProps["YourPhoneWinTitle"] := "Your Phone"
iniProps["YourPhoneCommand"] := "MicrosoftYourPhone_8wekyb3d8bbwe!App"
iniProps := WTSFunctions_readINI(pathINI, iniProps, iniSection)
TeamsHide := iniProps["TeamsHide"]
SlackHide := iniProps["SlackHide"]
OutlookHide := iniProps["TeamsHide"]
3cxHide := iniProps["3cxHide"]
8by8Hide := iniProps["8by8Hide"]
YourPhoneHide := iniProps["YourPhoneHide"]
outlookKey := iniProps["outlookKey"]
slackKey := iniProps["slackKey"]
teamsKey := iniProps["teamsKey"]
8by8Key := iniProps ["8by8Key"]
YourPhoneKey := iniProps["YourPhoneKey"]
teamsCommand := iniProps["teamsCommand"]
slackCommand := iniProps["slackCommand"]
slackWinTitle := iniProps["slackWinTitle"]
8by8WinTitle := iniProps["8by8WinTitle"]
8by8Command := iniProps["8by8Command"]
YourPhoneWinTitle := iniProps["YourPhoneWinTitle"]
YourPhoneCommand := iniProps["YourPhoneCommand"]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Main Code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
Hotkey, %outlookKey%, outlook
Hotkey, %teamsKey%, teams
Hotkey, %slackKey%, slack
Hotkey, %8by8Key%, 8by8
Hotkey, %YourPhoneKey%, yourPhone
return
outlook:
if WinExist("- Outlook")
{
WTSFunctions_winShow(OutlookHide)
} else {
try run Outlook.exe
catch e
MsgBox, 16, Outlook Error, Didn't find Outlook Window`nUnable to run Outlook`n%e%
}
return
teams:
if WinExist("| Microsoft Teams") or WinExist("ahk_exe Teams.exe")
{
WTSFunctions_winShow(TeamsHide)
} else {
try run %teamsCommand%
catch e
MsgBox, 16, Teams Error, Didn't find Teams window`nUnable to run Teams`n%e%
}
return
slack:
if WinExist(slackWinTitle)
{
WTSFunctions_winShow(SlackHide)
} else {
try run %slackCommand%
catch e
MsgBox, 16, Slack Error, Didn't find Slack window`nUnable to run Slack`n%e%
}
return
8by8:
if WinExist(8by8WinTitle)
{
WTSFunctions_winShow(8by8Hide)
} else {
try run %8by8Command%
catch e
MsgBox, 16, 8x8 Work Error, Didn't find 8x8 Work window`nUnable to run 8x8 Work`n%e%
}
return
yourPhone:
if WinExist(YourPhoneWinTitle)
{
WTSFunctions_winShow(YourPhoneHide)
} else {
try run %YourPhoneCommand%
catch e
MsgBox, 16, Your Phone Error, Didn't find Your Phone window`nUnable to run Your Phone`n%e%
}
return
; ^!p::gotoChannel("DE{space}-{space}TS") ; Direct access to DE - TS "general" channel
; ^!l::gotoChannel("Lunch") ; Direct access to DE - TS "lunch" channel
^!1:: ; Opens "Activities"
error := activateTeams()
if !error
{
SendInput, ^1
} else {
errorHandler("teams", error)
}
return
^!2:: ; Opens "Chat"
error := activateTeams()
if !error
{
SendInput, ^2
} else {
errorHandler("teams", error)
}
return
^!3:: ; Opens "Teams"
error := activateTeams()
if !error
{
SendInput, ^3
} else {
errorHandler("teams", error)
}
return
gotoChannel(channel)
{
error := activateTeams()
if !error
{
Send, ^e
Sleep, 50
Send, /
Sleep, 100
Send, goto
Sleep, 100
Send, {space}
Sleep, 400
Send, %channel%
Sleep, 200
Send, {tab}{enter}
} else {
errorHandler("teams", error)
}
}
activateTeams()
{
if WinExist("| Microsoft Teams") ; Check to make sure Teams is running
{
WinGet, Style, Style
If !(Style & 0x10000000)
WinRestore
WinActivate
WinActivate ; Not sure why this has to be sent twice, seems to be related to virtual desktops
WinWaitActive, , , 1 ; Make sure window got activated within 1 second
If ErrorLevel ; Run if window did not activate within timeout value
{
return 1
}
return 0
} else {
return 2
}
}
errorHandler(errorSource, errorNo)
{
if errorSource = teams
{
if errorNo = 1
MsgBox, 8208, Error, "Teams timed out, try again."
else if (errorNo = 2)
MsgBox, 8208, Error, "Didn't find Teams, try again."
else
MsgBox, 8208, Error, "Unspecified error."
}
}