-
Notifications
You must be signed in to change notification settings - Fork 4
/
GdipService.ahk
66 lines (55 loc) · 1.61 KB
/
GdipService.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
class GdipService {
SetToken() {
If !this.gdipToken := Gdip_Startup()
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
} else
{
;MsgBox, oo
}
}
SetWinTitle(winTitle) {
this.hwnd := WinExist(winTitle)
return this.hwnd
}
GetHwnd() {
return this.hwnd
}
GetBmpHaystack() {
this.bmpHaystack := Gdip_BitmapFromHWND(this.hwnd)
return this.bmpHaystack
}
GdipImageSearch(imagePath = "img/pk.png", direction = 1) {
this.SetToken()
LIST = 0
this.bmpHaystack := Gdip_BitmapFromHWND(this.hwnd)
this.bmpNeedle := Gdip_CreateBitmapFromFile(imagePath)
;RET := Gdip_ImageSearch(this.bmpHaystack, this.bmpNeedle, LIST, 0, 0, 0, 0, 100, "0xFFFFFF", direction, 1)
RET := Gdip_ImageSearch(this.bmpHaystack, this.bmpNeedle, LIST, 0, 0, 0, 0, 100, , direction, 1)
;MsgBox % this.bmpHaystack "_" bmpNeedle "_" RET "_" LIST
Gdip_DisposeImage(this.bmpNeedle)
Gdip_DisposeImage(this.bmpHaystack)
this.ShutDownGdip()
return List
}
Capture(title) {
FileCreateDir, capture
formattime, nowtime,,yyyy-MM-dd_HH-mm-ss
;MsgBox % nowtime
;Gdip_SetBitmapToClipboard(this.bmpHaystack)
this.bmpHaystack := Gdip_BitmapFromHWND(this.hwnd)
Gdip_SaveBitmapToFile(this.bmpHaystack, "capture/Capture_" . title . "_" . nowtime . ".png", 100)
Gdip_DisposeImage(this.bmpHaystack)
return
}
ShutDownGdip() {
Gdip_Shutdown(this.gdipToken)
VarSetCapacity(this.gdipToken,0)
VarSetCapacity(this.hwnd,0)
VarSetCapacity(this.bmpHaystack,0)
VarSetCapacity(this.bmpNeedle,0)
VarSetCapacity(this.RET,0)
return
}
}