Code: Select all
SetTimer, % timer, -10
Code: Select all
SetTimer, % timer, -0
Code: Select all
SetTimer, % timer, -10
Code: Select all
SetTimer, % timer, -0
Code: Select all
read_bitmap(hwnd)
{
pBitmap := Gdip_BitmapFromScreen( "hwnd:" hwnd)
pBitmap2 := Gdip_CropImage(pBitmap, 300, 413, 150, 60)
hBitmap := Gdip_CreateHBITMAPFromBitmap(pBitmap2)
pIRandomAccessStream := HBitmapToRandomAccessStream(hBitmap)
Found_Text := ocr(pIRandomAccessStream)
DeleteObject(hBitmap)
Gdip_DisposeImage(pBitmap)
Gdip_DisposeImage(pBitmap2)
}
Gdip_CropImage(pBitmap, x, y, w, h)
{
pBitmap2 := Gdip_CreateBitmap(w, h), G2 := Gdip_GraphicsFromImage(pBitmap2)
Gdip_DrawImage(G2, pBitmap, 0, 0, w, h, x, y, w, h)
Gdip_DeleteGraphics(G2)
return pBitmap2
}
Code: Select all
MsgBox, % ObjRelease(IRandomAccessStream)
MsgBox, % ObjRelease(BitmapDecoder)
MsgBox, % ObjRelease(BitmapFrame)
MsgBox, % ObjRelease(BitmapFrameWithSoftwareBitmap)
MsgBox, % ObjRelease(SoftwareBitmap)
MsgBox, % ObjRelease(OcrResult)
MsgBox, % ObjRelease(LinesList)
Code: Select all
MsgBox, % ObjRelease(IRandomAccessStream)
ObjRelease(BitmapDecoder)
ObjRelease(BitmapFrame)
ObjRelease(BitmapFrameWithSoftwareBitmap)
ObjRelease(SoftwareBitmap)
ObjRelease(OcrResult)
ObjRelease(LinesList)
Code: Select all
ObjRelease(BitmapDecoder)
ObjRelease(BitmapFrame)
ObjRelease(BitmapFrameWithSoftwareBitmap)
ObjRelease(SoftwareBitmap)
ObjRelease(OcrResult)
ObjRelease(LinesList)
MsgBox, % ObjRelease(IRandomAccessStream)
I have the smae issue with ewerybody, Windows 10 pro 20h2 tooteadrinker wrote: ↑07 Feb 2021, 13:27@ewerybody
Can't reproduce the issue. All latest updates are installed. Windows 10 Pro 20H2.
Code: Select all
#Include <OCRold> ; Optical character recognition (OCR) with UWP API, original version
NumpadMult::
{
img := "Q:\Down\1.png"
text := OCR(img)
Msgbox % text
return
}
Code: Select all
#Include <OCR> ; Optical character recognition (OCR) with UWP API, the version that can ocr from screen
NumpadMult::
{
img := "Q:\Down\1.png"
text := OCR(img)
Msgbox % text
return
}
ocrold.ahk is exact code copied from the first block of OPteadrinker wrote: ↑19 Jul 2021, 17:01Perhaps, your OCR class is incorrect. I can't know, what it contains.
Oh thanks I know what's the problem nowswagfag wrote: ↑23 Jul 2021, 09:20like @malcev wrote, one code is for use with files(or rather filenames, strings) and the other for use with screenshots(or rather IRandomAccessStreams, the bytes of which could come from anywhere u like)
what ure doing in both ur test examples is pass a filename(as a string), so its no wonder one of the examples isnt working(its expecting an IRandomAccessStream interface pointer, not a filename string!!)
Code: Select all
ocr(args *){
if(typeof args is string){
originalOCR.call(args)
} else if (typeof args is pIRandomAccessStream){
screenOCR.call(args)
}
}
Return to “Scripts and Functions (v1)”
Users browsing this forum: No registered users and 114 guests