-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpixelDN.ahk
110 lines (95 loc) · 2.18 KB
/
pixelDN.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
#Include Gdip.ahk
; Path to image
imageFile := "image.png"
; Initialize GDIP and load image
GDIPToken := Gdip_Startup()
pBM := Gdip_CreateBitmapFromFile(imageFile)
; Get dimensions
W:= Gdip_GetImageWidth(pBM)
H:= Gdip_GetImageHeight(pBM)
; Get TOL deathnote rectangle
screenX := 700
screenY := 175
width = 520
height = 750
; Calculate the zoom factor and draw a centralized image
ratio := width/W
if (ratio > height/H)
{
ratio := height/H
}
widthActual := W * ratio
heightActual := H * ratio
xOffset := (width - widthActual) / 2
yOffset := (height - heightActual) / 2
; Detect points and lines
drawBegin := 0
xBegin := 0
xEnd := 0
; Draw a portion of the image.
division := 3
drawDiv := 0
InputBox, drawDiv, Select Part to Draw, Enter 0 or 1 or 2
jFrom := H * drawDiv / division
jTo := H * (drawDiv + 1) / division
i := 0
j := jFrom
pixels := (jTo - jFrom) * W
; Looping and draw dark pixels
Loop, %pixels%
{
ARGB := GDIP_GetPixel(pBM, i, j)
B := ARGB & 255
G := (ARGB >> 8) & 255
R := (ARGB >> 16) & 255
; Calculate the target position of pixel
x := screenX + xOffset + i * ratio
y := screenY + yOffset + j * ratio
; Using only the blue channel
if (B < 128)
{
if (drawBegin == 0)
{
drawBegin := 1
xBegin := x
xEnd := x
}
else
{
xEnd := x
}
; MsgBox, From %xBegin% to %xEnd%
}
else
{
if (drawBegin == 1)
{
if (xBegin == xEnd)
{
; Click on a point
MouseMove, xBegin, y
MouseClick, Left, xBegin, y
; MsgBox, MouseClick At %xBegin%, %y%
}
else
{
; There is a straight line
MouseMove, xBegin, y
MouseClickDrag, Left, xBegin, y, xEnd, y, 7
; MsgBox, MouseClickDrag From %xBegin%, %y% to %xEnd%, %y%
}
drawBegin := 0
}
}
; Move to next pixel
i := i + 1
if (i == W)
{
i := 0
j := j + 1
drawBegin := 0
}
}
; Clean resources
GDIP_DisposeImage(pBM)
GDIP_Shutdown(GDIPToken)