-
Notifications
You must be signed in to change notification settings - Fork 1
/
Launcher.ahk
78 lines (74 loc) · 2.34 KB
/
Launcher.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
; DWIM function for command prompts
Prompt(title, path)
{
Launch(title, "C:\Windows\System32\cmd.exe /k title " . title . " & cd " . path)
}
;;; Notification
; CleanNotification()
; {
; ; ToolTip
; Progress(off)
; }
Notify(text)
{
; SysGet(Area, MonitorWorkArea)
; Y := AreaBottom-128
; Progress(hide Y%Y% W1000 b zh0 cwFFFFFF FM16 CT00BB00,, %text%, AutoHotKeyProgressBar, Backlash BRK)
; WinSet(TransColor, FFFFFF 255, AutoHotKeyProgressBar)
; Progress(show)
; SetTimer(CleanNotification, -2000)
}
; DWIM function to activate, launch, or minimize a window. Activates window with
; matching title if it exists or launches program if it doesn't exists and
; forces activation. Minimizes window if already active (use as toggle).
Launch(title, path, WorkDir:="", DetectHidden:=False)
{
DetectHiddenWindows DetectHidden
if WinExist(title)
{
If WinActive()
{
out := WinGetMinMax(title)
If (out = -1)
{
Notify("Restore " . title)
WinRestore ; store if minimized
}
Else
{
Notify("Minimize " . title)
WinMinimize ; minimize if active
}
}
Else
{
out := WinGetMinMax(title)
If (out != -1)
{
Notify("Restore " . title)
WinRestore ; restore if minimized
}
Notify("Activate " . title)
WinActivate ; bring to front
}
}
else
{
Notify("Launching " . path)
WinActivate("ahk_class Shell_TrayWnd") ; workaround to prevent window to open in background
Run path, WorkDir
WinWait(title)
WinActivate()
WinWait(title)
ToolTip()
}
DetectHiddenWindows False
}
;; Examples:
;;
;; EnvGet, LocalAppData, LOCALAPPDATA
;; #t::Launch("ahk_class TTOTAL_CMD", "C:\Program Files\TOTALCMD\TOTALCMD64.EXE")
;; #o::Launch("Outlook ahk_class OlkWV2Frame ahk_exe olk.exe", "C:\Program Files\Microsoft Office\root\Office16\OUTLOOK.EXE", DetectHidden=true)
;; #y::Launch("ahk_exe Teams.exe", LocalAppData . "\Microsoft\Teams\current\Teams.exe")
;; #+k::Launch("KeePassXC", "C:\Program Files\KeePassXC\KeePassXC.exe")
;; #c::Launch("ahk_exe qalculate-qt.exe", "c:\Program Files\Qalculate\qalculate-qt.exe")