-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBossKey.ahk
126 lines (82 loc) · 2.41 KB
/
BossKey.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
#NoTrayIcon
SetTitleMatchMode, 2
SetBatchLines, 10ms
SetWinDelay, 10
B = 1
;______Windows not to hide__________________
;These window titles will be immune to the Boss key.
;don't remove 'hid1 = Shell_TrayWnd'
hid1 = Shell_TrayWnd
hid2 = Microsoft Word
;hid3 = Microsoft OneNote
;______Apps to launch_______________________
;These apps will be launched when Boss key is pressed.
;Takes care of situation when you were not working at all!
;Syntax: FilePath|WinTitle
;Giving WinTitle will make the script NOT launch an app
;if its window already exists, not giving wintitle will
;make the app be launched unconditionally
;Run0 = %windir%\system32\calc.exe|Calculator
;Run1 = C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE|Inbox - [email protected] - Microsoft Outlook
;Run2 = E:\dos\batch\messages.txt|messages.txt - Notepad
;______Set Hotkeys here_____________________
Hotkey, ^+!z, Boss ;This is the Boss key
^#z::ExitApp ;As the icon is hidden, use this hotkey to exit the script
Exit
Boss:
;hides all windows with exceptions
IfGreater, B, 0
{
;get all ids
WinGet, id, list,,, Program Manager
;loop for all windows
Loop, %id%
{
StringTrimRight, this_id, id%a_index%, 0
;get current win title
WinGetTitle, title, ahk_id %this_id%
;get current win class
WinGetClass, class, ahk_id %this_id%
ToHide = y
;see if this is NOT to be hidden
Loop
{
StringTrimRight, CWin, hid%A_Index%, 0
IfEqual, CWin,, Break
IfInString, title, %CWin%, SetEnv, ToHide, n
IfInString, class, %CWin%, SetEnv, ToHide, n
IfEqual, ToHide, n, Break
}
;hide windows and keep a record of windows hidden
IfEqual, ToHide, y
{
WinHide, ahk_id %this_id%
HWins = %HWins%||%this_id%
}
}
}
;shows hidden windows
IfLess, B, 0
{
;show windows
Loop, Parse, HWins, ||
WinShow, ahk_id %A_LoopField%
}
;opens work windows
IfGreater, B, 0
{
Loop
{
StringTrimLeft, CRun, Run%A_Index%, 0
IfEqual, CRun,, Break
StringGetPos, ppos, CRun, |
StringLeft, fpath, CRun, %ppos%
IfEqual, fpath,, SetEnv, fpath, %CRun%
StringTrimLeft, wname, CRun, %ppos%
StringTrimLeft, wname, wname, 1
WinShow, %wname%
IfWinNotExist, %wname%,, IfExist, %fpath%, Run, %fpath%
}
}
B *= -1
Return