Monday, January 15, 2018

sample 5&6 screen shot and OCR

#s::
WinGetTitle, Title, A

ss(Title)
{
filename=d:\script\%A_DD%-%A_MMM%-%A_YYYY%-%A_Hour%-%A_min%.png
;msgbox %x%
;sleep,2000
;send, {Alt down}{PrintScreen}{Alt up}
;ClipWait,1
GDIPToken:=Gdip_Startup()
;pBM:=Gdip_CreateBitmapFromClipboard()
hwnd:=WinExist(Title)
pBM := Gdip_BitmapFromHWND(hwnd)
Sleep, 2000
Gdip_SaveBitmapToFile(pBM, filename)
Sleep, 2000
Gdip_DisposeImage( pBM )
Gdip_Shutdown( GDIPToken )
;Run, D:\autohotkey\runerp.log
;WinActivate, runerp - Notepad
;Sleep, 2000
;Send, %A_DD%/%A_MM%/%A_YYYY%  %A_hour%:%A_min%{Enter}
;WinActivate, runerp - Notepad
;Send, !{F4}
;Sleep, 2000
;Send, {Enter}
;sleep, 2000
}
return

;#################################################################################
OCR(i,j,x,y,text="",cx:=0,cy:=0)
{
WinGetPos, Xx, Yy, , , %Tx%
;msgbox %Xx% %Yy%
tt:=i+Xx . " " . j+Yy . " " . x+Xx . " " . y+Yy
;msgbox %tt%
;tt=1212 385 1247 405
;RunWait, D:\script\Capture2Text\Capture2Text_CLI.EXE -s "%tt%" --clipboard ,,HIDE
;ClipWait,1

RunWait, D:\Pdd26\script\Capture2Text\Capture2Text_CLI.EXE -s "%tt%" -o d:\temp.txt ,,HIDE

Loop, read, d:\temp.txt
{
    Loop, parse, A_LoopReadLine, %A_Tab%
    {
        clipboard=%A_LoopField%.
    }
}
;msgbox %clipboard%
tt=%clipboard%

loop 10
{
StringReplace, text, text,`n,
StringReplace, text, text,`r,
StringReplace, tt, tt,`n,
StringReplace, tt, tt,`r,
StringReplace, tt, tt,., ;for number check
}
tt:=tt+0 ;for number check

;msgbox -%tt%- | %text%
if (text="")
kk:=tt
else
{
if (instr(text,tt)>0)
{
kk:=1
if cx = 0
{
cx:=(i+x)/2
cy:=(j+y)/2
}
MouseClick,left ,cx,cy
mousemove,0,0
;pause
}
else
kk:=0
}
;msgbox %kk% , %text% , %clipboard%
return kk
}