-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAppKill.ahk
63 lines (55 loc) · 1.82 KB
/
AppKill.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
#SingleInstance, force ; Forces only one instance, allows to re-run script without reloading
Menu, Tray, Icon, images\WoosterGraphic.ico ; Icon for this script
Menu, Tray, Tip, WTS: AppKill ; Change tooltip on icon in tray
DetectHiddenWindows, On
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Initialization ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; Define INI file location
pathINI = % A_AppData "\Wooster Technical Solutions\WoosterTech.ini"
; Section of INI file for 3CX
iniSection = AppKill
; Initialize iniProps
iniProps := {}
; Properties from INI file with their defaults
iniProps["process_name"] := "Teams.exe"
iniProps["program_name"] := "Teams"
iniProps["wait_time"] := 3
iniProps["enableAppKill"] := true
iniProps["keyAppKill"] := "<^<!Numpad5"
iniProps := WTSFunctions_readINI(pathINI, iniProps, iniSection)
process_name := iniProps["process_name"]
program_name := iniProps["program_name"]
wait_time := iniProps["wait_time"]
enableAppKill := iniProps["enableAppKill"]
keyAppKill := iniProps["keyAppKill"]
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; Main Code ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
if enableAppKill
{
Hotkey, %keyAppKill%, appkill
return
appkill:
if WinExist("ahk_exe Teams.exe")
{
; MsgBox, Found Teams
; Process, Exist, %process_name% ; Check to make sure that it's running
; If ErrorLevel { ; Returns 0 if no matching program
ToolTip, Stopping %program_name%
Process, Close, %process_name%
; Process, Close, %process_name%
WinWaitClose, , , 3
if ErrorLevel
{
; Process, WaitClose, %process_name%, %wait_time% ; Ensure process is killed before continuing
; If ErrorLevel {
Tooltip
MsgBox, 16, AppKill, Unable to close %program_name%, 5
Exit
}
Tooltip, Teams Stopped
Sleep, 3000
ToolTip
; }
} else {
MsgBox, 16, AppKill, % "Did not find " program_name
}
return
}