-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtilingManagerTest.ahk
More file actions
207 lines (162 loc) · 3.89 KB
/
tilingManagerTest.ahk
File metadata and controls
207 lines (162 loc) · 3.89 KB
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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
#SingleInstance, force
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Menu, Tray, Icon, toggleScriptRed.ico
vertCells := 2
horCells := 6
CoordMode, Mouse, Screen
mode = 1
toResize := getWinTitle()
Done := 0
GoSub, start
ExitApp
start:
mon := GetMonitorMouse()
SysGet, mon, MonitorWorkArea, %mon%
monSizeX := monRight - monLeft
monSizeY := monBottom - monTop
cellSizeX := floor(monSizeX/horCells)
cellSizeY := floor(monSizeY/vertCells)
Gui Color, Black
Gui, +LastFound
Gui, +AlwaysOnTop
WinSet, Transparent, 100
Gui, -Caption
Gui Show, w%monSizeX% h%monSizeY% X%monLeft% Y%monTop%
WinSet, Region, 0-0 W0 H0
while getkeystate("LButton", "P") == 0{
MouseGetPos, x, y
x -= monLeft
y -= monTop
downXcell := x // cellSizeX
downYcell := y // cellSizeY
ToolTip, %downXcell% %downYcell% , 10, 10
winStartX := downXcell*cellSizeX
winStartY := downYcell*cellSizeY
if (mon != GetMonitorMouse()){
Goto, start
}
WinSet, Region, %winStartX%-%winStartY% W%cellSizeX% H%cellSizeY%
}
KeyWait, LButton, D
if (mode != 1){
goSub, $Escape
}
Menu, Tray, Icon, toggleScriptGreen.ico
while getkeystate("LButton", "P") == 1{
MouseGetPos, x, y
x -= monLeft
y -= monTop
upXcell := x // cellSizeX
upYcell := y // cellSizeY
startXcell := Min(downXcell, upXcell)
startYcell := Min(downYcell, upYcell)
spanX := Abs(downXcell - upXcell) + 1
spanY := Abs(downYcell - upYcell) + 1
winStartX := startXcell*cellSizeX
winStartY := startYcell*cellSizeY
ToolTip, %spanX% %spanY% , 10, 10
winRegionX := spanX*cellSizeX
winRegionY := spanY*cellSizeY
WinSet, Region, %winStartX%-%winStartY% W%winRegionX% H%winRegionY%
}
winStartX += monLeft
winStartY += monTop
WinRestore, %toResize%
WinMove, %toResize%,, %winStartX%, %winStartY%, %winRegionX%, %winRegionY%
WinActivate, %toResize%
mode = 0
Gui, Destroy
ToolTip
return
GetMonitorMouse(){
MouseGetPos, x, y
SysGet, numOfMonitors, 80
i := 1
while (i <= numOfMonitors){
SysGet, mon, MonitorWorkArea, %i%
if (x <= monRight && x >= monLeft && y <= monBottom && y >= monTop)
{
Return %i%
}
i++
}
MsgBox,16,,Your mouse isn't on a monitor???????? quiting, 2
ExitApp
}
getWinTitle(){
;get the active window
WinGet, id, ID, A
;get the title from the active window
WinGetTitle, windowTitle, ahk_id %id%
;break up the window title - is the delimiter drop spaces
return windowTitle
}
$Escape::
mode = 0
Gui, Destroy
ToolTip
ExitApp
Return
#If mode ; All hotkeys below this line will only work if mode is TRUE
LButton::
if (mode == 1){
Return
}
if (mode > 1){
ExitApp
}
return
#If
$RButton::
mode := 2
if (Done == 0){
Menu, Windows, Add
Menu, Windows, deleteAll
WinGet windows, List
Menu, Windows, Add, Done, $Escape
Menu, Windows, Default, Done
Loop %windows%
{
id := windows%A_Index%
WinGetTitle title, ahk_id %id%
If (title = "")
continue
WinGetClass class, ahk_id %id%
If (class = "ApplicationFrameWindow")
{
WinGetText, text, ahk_id %id%
If (text = "")
continue
}
WinGet, style, style, ahk_id %id%
if !(style & 0xC00000) ; if the window doesn't have a title bar
{
; If title not contains ... ; add exceptions
continue
}
WinGet, Path, ProcessPath, ahk_id %id%
Menu, Windows, Add, %title%, Activate_Window
Try
Menu, Windows, Icon, %title%, %Path%,, 0
Catch
Menu, Windows, Icon, %title%, %A_WinDir%\System32\SHELL32.dll, 3, 0
}
Done := 1
}Else{
Menu, Windows, Disable, %Done%
}
Menu, Windows, Show
return
Activate_Window:
mode := 1
SetTitleMatchMode, 3
toResize := A_ThisMenuItem
Done := A_ThisMenuItem
GoSub, start
GoSub, $RButton
return
$MButton::
WinMinimizeAll
return