Yup, ~2 milliseconds on my pc, and that's without the fancy rotating stuff.
The basics
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
;Be sure $posx and $posy is pointing at the correct spot!
Global $posx = 1718, $posy = 699, $result = ""
;Lookup table to avoid searching
Global $digit[115] = [1,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0, _
0,0,0,0,0,0,0,0,0,0,6,0,0,0,3,2,0,0,0,0, _
0,0,0,0,0,0,0,0,9,0,0,0,0,0,8,0,0,0,0,0, _
0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _
0,0,0,0,0,0,0,0,0,0,0,0,0,0,5]
$capture = _ScreenCapture_Capture("", $posx, $posy, $posx+34, $posy+20)
$bitmap = _GDIPlus_BitmapCreateFromHBITMAP($capture); for some reason createfromhbitmap is not a fully compatible gdiplus bitmap
$clone = _GDIPlus_BitmapCloneArea($bitmap, 0, 0, 34, 20, $GDIP_PXF32ARGB); so we have to do this before it works correctly
_GDIPlus_BitmapDispose($bitmap)
Func Getnumber($result)
Local $code[3] = [0,0,0], $value = 64
$bitmap1 = _GDIPlus_BitmapLockBits($clone, 0, 0, 34, 20, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB)
$pixels = DllStructCreate("dword[" & 680 & "];", DllStructGetData($bitmap1, "Scan0"))
For $loop = 1 To 680 Step 102
$code[0] += DllStructGetData($pixels, 1, $loop ) = 4278255360 ? $value:0
$code[1] += DllStructGetData($pixels, 1, $loop+16) = 4278255360 ? $value:0
$code[2] += DllStructGetData($pixels, 1, $loop+32) = 4278255360 ? $value:0
$value /= 2
Next
_GDIPlus_BitmapUnlockBits($clone, $bitmap1)
Return String($digit[$code[0]]) & String($digit[$code[1]]) & String($digit[$code[2]])
EndFunc
And a runable script (zipped folder with script and test images attached)
#include <GDIPlus.au3>
#include <ScreenCapture.au3>
HotKeySet("{ESC}", "_exit")
;Be sure $posx and $posy is pointing at the correct spot!
Global $posx = 1718, $posy = 699, $result = ""
;Lookup table to avoid searching
Global $digit[115] = [1,0,0,0,0,0,0,0,0,0,0,0,4,0,0,0,0,0,0,0, _
0,0,0,0,0,0,0,0,0,0,6,0,0,0,3,2,0,0,0,0, _
0,0,0,0,0,0,0,0,9,0,0,0,0,0,8,0,0,0,0,0, _
0,0,0,0,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _
0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, _
0,0,0,0,0,0,0,0,0,0,0,0,0,0,5]
;Test section
;--------------------------------------------------------------
$gui = GUICreate("Getnumber", 640, 480, -1, -1)
GUISetState()
WinWaitActive($gui); <--- necessary or screencapture fails
_GDIPlus_Startup()
$graphics = _GDIPlus_GraphicsCreateFromHWND($gui)
$image = _GDIPlus_BitmapCreateFromFile("518.png")
_GDIPlus_GraphicsDrawImageRect($graphics, $image, 280, 200, 136, 31)
Sleep(10); <------- necessary because drawimagerect() is too slow, script occasionally fails without
;--------------------------------------------------------------
;/Test section
$time = TimerInit()
$capture = _ScreenCapture_Capture("", $posx, $posy, $posx+34, $posy+20)
$bitmap = _GDIPlus_BitmapCreateFromHBITMAP($capture); for some reason createfromhbitmap is not a fully compatible gdiplus bitmap
$clone = _GDIPlus_BitmapCloneArea($bitmap, 0, 0, 34, 20, $GDIP_PXF32ARGB); so we have to do this before it works correctly
_GDIPlus_BitmapDispose($bitmap)
$result = Getnumber()
Consolewrite("Result: " & $result & " Time: " & TimerDiff($time)/1000 & @crlf)
While 1
Sleep(10)
WEnd
Func Getnumber()
Local $code[3] = [0,0,0]
$bitmap1 = _GDIPlus_BitmapLockBits($clone, 0, 0, 34, 20, BitOR($GDIP_ILMWRITE, $GDIP_ILMREAD), $GDIP_PXF32ARGB)
$pixels = DllStructCreate("dword[" & 680 & "];", DllStructGetData($bitmap1, "Scan0"))
$value = 64
For $loop = 1 To 680 Step 102
$code[0] += BitAnd(BitShift(DllStructGetData($pixels, 1, $loop ), 8), 1) = 1 ? $value:0
$code[1] += BitAnd(BitShift(DllStructGetData($pixels, 1, $loop+16), 8), 1) = 1 ? $value:0
$code[2] += BitAnd(BitShift(DllStructGetData($pixels, 1, $loop+32), 8), 1) = 1 ? $value:0
$value /= 2
Next
$result = String($digit[$code[0]]) & String($digit[$code[1]]) & String($digit[$code[2]])
$code = 0
_GDIPlus_BitmapUnlockBits($clone, $bitmap1)
Return $result
EndFunc
Func _exit()
_GDIPlus_Shutdown()
Exit
EndFunc
Not much code it takes.
I havent checked for memoryleaks and stuff, too tired now, if you spot anyting please tell.
Be sure to change the $posx and $posy to point at the correct spot, as it is now it fits a 3440x1440 monitor.
(you can comment out line 56 that gives error so you can take a screenshot to find the correct spot)
/edit
Changed, zip not updated
Changed again,
$code[0] += DllStructGetData($pixels, 1, $loop ) = 4278255360 ? $value:0
$code[1] += DllStructGetData($pixels, 1, $loop+16) = 4278255360 ? $value:0
$code[2] += DllStructGetData($pixels, 1, $loop+32) = 4278255360 ? $value:0
getnumber.zip