-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.au3
93 lines (81 loc) · 2.39 KB
/
utils.au3
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
#include <ScreenCapture.au3>
Func MouseTo($box)
; to troubleshoot boxes:
;MouseMove($box[0], $box[1], 2)
;Sleep(500)
;MouseMove($box[0], $box[3], 2)
;Sleep(500)
;MouseMove($box[2], $box[1], 2)
;Sleep(500)
;MouseMove($box[2], $box[3], 2)
;Sleep(500)
MouseMove(Random($box[0], $box[2]), Random($box[1], $box[3]), 2)
EndFunc ;==>MouseTo
Func Click($box)
MouseTo($box)
;Sleep(500)
MouseClick("left")
EndFunc ;==>Click
Func WriteValue($box, $val)
Click($box)
Sleep(Random(10, 20))
Send("{BS}")
Sleep(Random(10, 20))
Send("{BS}")
Sleep(Random(10, 20))
Send("{BS}")
Sleep(Random(10, 20))
Send("{DEL}")
Sleep(Random(10, 20))
Send("{DEL}")
Sleep(Random(10, 20))
Send("{DEL}")
Sleep(Random(10, 20))
$split = StringSplit("" & $val, "")
For $i = 1 To $split[0]
Send($split[$i])
Sleep(Random(10, 20))
Next
EndFunc ;==>WriteValue
Func Search()
;Move mouse away from search button:
MouseTo($boxCraftingMenu0Arrow)
Sleep(1000)
Local $searchDoneSum = PixelChecksum($boxSearch[0], $boxSearch[1], $boxSearch[2], $boxSearch[3], 2)
Click($box)
MouseMove(1, 1, 2)
;Wait for search to be done:
;ConsoleWrite("Waiting for search to finish...");
While 1
Sleep(50)
Local $searchSum = PixelChecksum($box[0], $box[1], $box[2], $box[3], 2)
If $searchSum == $searchDoneSum Then
ExitLoop
Else
;ConsoleWrite('.')
EndIf
WEnd
;ConsoleWrite(" done." & @CRLF);
EndFunc
Func Search()
ClickWait($boxSearch)
EndFunc ;==>Search
Func OCRBox($box, $arg, $filename="out")
return OCR($box[0], $box[1], $box[2], $box[3], $arg, $filename)
EndFunc
Func OCR($x1, $y1, $x2, $y2, $arg, $filename="out")
_ScreenCapture_Capture($filename & ".bmp", Int($x1), Int($y1), Int($x2), Int($y2), False)
;RunWait(@ComSpec & " /c " & '"D:\Program Files (x86)\ImageMagick-6.8.6-Q16\convert" ' & $filename & ".bmp " & "-colorspace gray -negate -threshold 92% " & $filename & ".png ", "", @SW_HIDE)
If Not StringCompare(@OSVersion , "Win_7") Then
$command = @ComSpec & " /c " & '"D:\Program Files (x86)\Tesseract-OCR\tesseract" ' & $filename & ".bmp " & $filename & " " & $arg
Else
$command = @ComSpec & " /c " & '"C:\Program Files\Tesseract-OCR\tesseract" ' & $filename & ".bmp " & $filename & " " & $arg
EndIf
;ConsoleWrite($command & @LF)
RunWait($command, "", @SW_HIDE)
$s = FileRead($filename & ".txt")
Return $s
EndFunc
Func BoxChecksum($box)
Return PixelChecksum($box[0], $box[1], $box[2], $box[3], 2)
EndFunc