-
Notifications
You must be signed in to change notification settings - Fork 72
/
Copy pathCensorbox.ahk
138 lines (112 loc) · 2.8 KB
/
Censorbox.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
; Link:
; Author:
; Date:
; for: AHK_L
/*
*/
; =================================================================================================================================
; Name: CENSOR BOX
; Description: Hide parts of the screen with a colored box
; credits: Speedmaster, Lexikos
; Topic: https://www.autohotkey.com/boards/viewtopic.php?f=6&t=78160
; Sript version: 1.0
; AHK Version: 1.1.24.03 (A32/U32/U64)
; Tested on: Win 7
; shortcuts:: f1 add a new box
; f2 color the box with the top left pixel
; f3 freeze/unfreeze all boxes
; all boxes are resizable with the mouse
#SingleInstance force
OnMessage(0x201, "WM_LBUTTONDOWN")
OnMessage(0x84, "WM_NCHITTEST")
OnMessage(0x83, "WM_NCCALCSIZE")
OnMessage(0x86, "WM_NCACTIVATE")
CoordMode,pixel, screen
if !count
goto newbox
return
F1::
newbox:
count++
Gui box_%count%: -caption +AlwaysOnTop +resize ;+LabelGui +AlwaysOnTop +LastFound +resize -caption
Gui box_%count%: show, w100 h100 , box_%count%
Gui box_%count%: color, black
return
f2::
WinGetPos,px,py,,, %currentgui%
PixelGetColor, outcolor, % px-1, % py-1, RGB
gui %currentgui%: color, % outcolor
return
f3::
freeze:=!freeze
if freeze
loop, % count
gui box_%a_index%: -resize
else
loop, % count
gui box_%a_index%: +resize
return
WM_LBUTTONDOWN() {
global currentgui, freeze
MouseGetPos, xpos, ypos
(A_Gui) && currentgui:=a_gui
(A_Gui) && (!freeze) && move()
}
move() {
PostMessage, 0xA1, 2 ; WM_NCLBUTTONDOWN
}
; thx Lexikos
; https://autohotkey.com/board/topic/23969-resizable-window-border/
; Sizes the client area to fill the entire window.
WM_NCCALCSIZE()
{
if A_Gui
return 0
}
; Prevents a border from being drawn when the window is activated.
WM_NCACTIVATE()
{
if A_Gui
return 1
}
; Redefine where the sizing borders are. This is necessary since
; returning 0 for WM_NCCALCSIZE effectively gives borders zero size.
WM_NCHITTEST(wParam, lParam)
{
static border_size = 6
if !A_Gui
return
WinGetPos, gX, gY, gW, gH
x := lParam<<48>>48, y := lParam<<32>>48
hit_left := x < gX+border_size
hit_right := x >= gX+gW-border_size
hit_top := y < gY+border_size
hit_bottom := y >= gY+gH-border_size
if hit_top
{
if hit_left
return 0xD
else if hit_right
return 0xE
else
return 0xC
}
else if hit_bottom
{
if hit_left
return 0x10
else if hit_right
return 0x11
else
return 0xF
}
else if hit_left
return 0xA
else if hit_right
return 0xB
; else let default hit-testing be done
}
return
guiclose:
~esc::
exitapp