SHOW:
|
|
- or go back to the newest paste.
| 1 | #include <GDIPlus.au3> | |
| 2 | #include <ScreenCapture.au3> | |
| 3 | ||
| 4 | Global $Title = WinGetTitle("7 Giây Để Chiến Thắng")
| |
| 5 | Global $HWnD = WinGetHandle($Title) | |
| 6 | Global $cSize = WinGetClientSize($HWnD) | |
| 7 | Global $wSize = WinGetPos($HWnD) | |
| 8 | Global $borderSize = ($wSize[2] - $cSize[0]) / 2 | |
| 9 | Global $captionSize = ($wSize[3] - $cSize[1]) - $borderSize | |
| 10 | Global $hBitmap | |
| 11 | ||
| 12 | _GDIPlus_Startup() | |
| 13 | ||
| 14 | WinActivate($HWnD) | |
| 15 | ControlClick($HWnD, "", "[NAME:batdau]") | |
| 16 | Sleep(500) | |
| 17 | ||
| 18 | _CaptureRegion($wSize[0] + $borderSize, $wSize[1] + $captionSize, $wSize[0] + $borderSize + $cSize[0], $wSize[1] + $captionSize + $cSize[1]) | |
| 19 | ||
| 20 | $Plus1 = OCR(63, 94, 88, 108) | |
| 21 | $Plus2 = OCR(196, 94, 219, 108) | |
| 22 | $Minus1 = OCR(63, 141, 88, 155) | |
| 23 | $Minus2 = OCR(196, 141, 219, 155) | |
| 24 | $Mul1 = OCR(63, 188, 88, 202) | |
| 25 | $Mul2 = OCR(196, 188, 219, 202) | |
| 26 | $Div1 = OCR(63, 235, 88, 249) | |
| 27 | $Div2 = OCR(196, 235, 219, 249) | |
| 28 | ||
| 29 | ControlSetText("", "", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:1]", $Plus1 + $Plus2)
| |
| 30 | ControlSetText("", "", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:4]", $Minus1 - $Minus2)
| |
| 31 | ControlSetText("", "", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:3]", $Mul1 * $Mul2)
| |
| 32 | ControlSetText("", "", "[CLASS:WindowsForms10.EDIT.app.0.378734a; INSTANCE:2]", $Div1 / $Div2)
| |
| 33 | ||
| 34 | Func OCR($a, $b, $c, $d) | |
| 35 | Local $Number = 0 | |
| 36 | Local $pStart = False | |
| 37 | Local $pCount = 0 | |
| 38 | For $i = $a To $c | |
| 39 | $pCheck = False | |
| 40 | For $j = $b To $d | |
| 41 | If _ColorCheckVariation(_PixelGetColor_GetPixel($i, $j), Hex(0x000000, 6), 100) Then | |
| 42 | $pStart = True | |
| 43 | $pCheck = True | |
| 44 | $pCount += 1 | |
| 45 | EndIf | |
| 46 | Next | |
| 47 | If Not $pCheck And $pStart Then | |
| 48 | $Number = 10 * $Number + OCRReturn($pCount) | |
| 49 | $pStart = False | |
| 50 | $pCount = 0 | |
| 51 | EndIf | |
| 52 | Next | |
| 53 | Return $Number | |
| 54 | EndFunc ;==>OCR | |
| 55 | ||
| 56 | Func OCRReturn($oCount) | |
| 57 | Switch $oCount | |
| 58 | Case 38 | |
| 59 | Return 0 | |
| 60 | Case 6 | |
| 61 | Return 1 | |
| 62 | Case 39 | |
| 63 | Return 2 | |
| 64 | Case 40 | |
| 65 | Return 3 | |
| 66 | Case 25 | |
| 67 | Return 4 | |
| 68 | Case 46 | |
| 69 | Return 5 | |
| 70 | Case 52 | |
| 71 | Return 6 | |
| 72 | Case 27 | |
| 73 | Return 7 | |
| 74 | Case 49 | |
| 75 | Return 8 | |
| 76 | Case 45 | |
| 77 | Return 9 | |
| 78 | EndSwitch | |
| 79 | EndFunc ;==>OCRReturn | |
| 80 | ||
| 81 | Func _CaptureRegion($iLeft, $iTop, $iRight, $iBottom) | |
| 82 | $hHBitmap = _ScreenCapture_Capture("", $iLeft, $iTop, $iRight, $iBottom)
| |
| 83 | $hBitmap = _GDIPlus_BitmapCreateFromHBITMAP($hHBitmap) | |
| 84 | ||
| 85 | EndFunc ;==>_CaptureRegion | |
| 86 | ||
| 87 | Func _PixelGetColor_GetPixel($iX, $iY) | |
| 88 | Local $aPixelColor = _GDIPlus_BitmapGetPixel($hBitmap, $iX, $iY) | |
| 89 | Return Hex($aPixelColor, 6) | |
| 90 | EndFunc ;==>_PixelGetColor_GetPixel | |
| 91 | ||
| 92 | Func _ColorCheckVariation($nColor1, $nColor2, $sVari = 5) | |
| 93 | Local $Red1, $Red2, $Blue1, $Blue2, $Green1, $Green2 | |
| 94 | $Red1 = Dec(StringMid(String($nColor1), 1, 2)) | |
| 95 | $Blue1 = Dec(StringMid(String($nColor1), 3, 2)) | |
| 96 | $Green1 = Dec(StringMid(String($nColor1), 5, 2)) | |
| 97 | $Red2 = Dec(StringMid(String($nColor2), 1, 2)) | |
| 98 | $Blue2 = Dec(StringMid(String($nColor2), 3, 2)) | |
| 99 | $Green2 = Dec(StringMid(String($nColor2), 5, 2)) | |
| 100 | If Abs($Blue1 - $Blue2) > $sVari Then Return False | |
| 101 | If Abs($Green1 - $Green2) > $sVari Then Return False | |
| 102 | If Abs($Red1 - $Red2) > $sVari Then Return False | |
| 103 | Return True | |
| 104 | EndFunc ;==>_ColorCheckVariation |