Advertisement
Guest User

Untitled

a guest
Nov 24th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Black.="|<0>*140$5.R6AMlWu"
  2. Black.="|<1>*140$5.4MEV24S"
  3. Black.="|<2>*140$5.S48F4Ey"
  4. Black.="|<3>*140$5.S49UV2u"
  5. Black.="|<4>*140$5.6QeTV26"
  6. Black.="|<5>*140$5.SV3kV2u"
  7. Black.="|<6>*140$5.CW7clmu"
  8. Black.="|<7>*140$5.S48l68m"
  9. Black.="|<8>*140$5.R6/dlWu"
  10. Black.="|<9>*140$5.R6ALV6u"
  11.  
  12. Fat.="|<0>*114$5.RiAMlqu"
  13. Fat.="|<1>*114$5.BslX6By"
  14. Fat.="|<2>*114$5.xAMnity"
  15. Fat.="|<3>*114$5.zAPVV7u"
  16. Fat.="|<4>*114$5.CRytz6C"
  17. Fat.="|<5>*114$5.zX7lV7u"
  18. Fat.="|<6>*114$5.TX7stqu"
  19. Fat.="|<7>*114$5.yANXANW"
  20. Fat.="|<8>*114$5.TjDjlny"
  21. Fat.="|<9>*114$5.RiCTX7u"
  22.  
  23. OLD:=FindTextOCR(765, 408, 9, 4, 0.2, 0.1, Fat)
  24. if (OLD < 0)
  25.     OLD := 0
  26. s:=10
  27. x:=0
  28. Ch:=0
  29. NEW:=""
  30. Gui +AlwaysOnTop
  31. Gui, Font, s264
  32. Gui, Add, Text,vOLD x0 y0 w550,0
  33. Gui, Add, Text,vNEW x0 y330 w550,0
  34. Gui, Show, w560 h700 x1000 y100
  35.  
  36. Loop
  37.     {
  38.     if WinActive("Предупреждение")
  39.         {
  40.         SoundPlay *16
  41.         Gui Err:Color, Red
  42.         Gui Err:Font, S64 CDefault Bold, Verdana
  43.         Gui Err:Add, Text, x2 y0 w790 h120 , Пункт выгрузки
  44.         Gui Err:Add, Text, x55 y110 w680 h110 , 1 - приписать
  45.         Gui Err:Add, Edit, vCh x332 y250 w130 h120 , 2
  46.         Gui Err:Add, Button, default gSubmit x582 y280 w170 h80 , ОК
  47.         Gui Err:Show, x100 y200 h392 w798, Пункт выгрузки
  48.         sleep 100
  49.         continue
  50.         }
  51.     if WinActive("Объект заблокирован")
  52.         {
  53.         Send {Left}
  54.         Sleep 100
  55.         Send {Enter}
  56.         continue
  57.         }
  58.     NEW:=FindTextOCR(765, 408, 9, 4, 0.2, 0.1, Fat)
  59.     if (NEW > 0)
  60.         {
  61.         if (OLD != NEW)
  62.             {
  63.             if (OLD > NEW)
  64.                 {
  65.                 if (x < 5)
  66.                     {
  67.                     x+=1
  68.                     sleep 250
  69.                     continue
  70.                     }
  71.                 else
  72.                     {
  73.                     SoundPlay *48
  74.                     x:=0
  75.                     }
  76.                 }
  77.             CNT := NEW - OLD
  78.             if (CNT > 5)
  79.                 {
  80.                 if (x < 5)
  81.                     {
  82.                     x+=1
  83.                     sleep 250
  84.                     continue
  85.                     }
  86.                 else
  87.                     {
  88.                     Soundplay *48
  89.                     x:=0
  90.                     }
  91.                 }
  92.             if (CNT <= 5)
  93.                 {
  94.                 Loop, %CNT%
  95.                     {
  96.                     SoundPlay *-1
  97.                     Sleep 200
  98.                     }
  99.                 }
  100.             GuiControl,,NEW,%NEW%
  101.             sleep 100
  102.             GuiControl,,OLD,%OLD%
  103.             OLD:=NEW
  104.             x:=0
  105.             }
  106.         }
  107.     Sleep 100
  108.     }
  109. Return
  110.  
  111. Submit:
  112. gui Err:submit, NoHide
  113. sleep 500
  114. gui Err:destroy
  115. if (Ch == 1)
  116.     {
  117.     clipboard := "3023443vsh"
  118.     sleep 250
  119.     send {Left}
  120.     Sleep 250
  121.     send {Enter}
  122.     sleep 250
  123.     send ^{vk56}
  124.     sleep 250
  125.     send {Enter}
  126.     }
  127. if (Ch != 1)
  128.     {
  129.     sleep 250
  130.     Send {Enter}
  131.     }
  132. ch:=0
  133. return
  134.  
  135. GuiClose:
  136. ExitApp
  137.  
  138. FindText(x,y,w,h,err1,err0,text)
  139. {
  140.   xywh2xywh(x-w,y-h,2*w+1,2*h+1,x,y,w,h)
  141.   if (w<1 or h<1)
  142.     return, 0
  143.   bch:=A_BatchLines
  144.   SetBatchLines, -1
  145.   ;--------------------------------------
  146.   GetBitsFromScreen(x,y,w,h,Scan0,Stride,bits)
  147.   ;--------------------------------------
  148.   sx:=0, sy:=0, sw:=w, sh:=h, arr:=[]
  149.   Loop, Parse, text, |
  150.   {
  151.     v:=A_LoopField
  152.     IfNotInString, v, $, Continue
  153.     comment:="", e1:=err1, e0:=err0
  154.     ; You Can Add Comment Text within The <>
  155.     if RegExMatch(v,"<([^>]*)>",r)
  156.       v:=StrReplace(v,r), comment:=Trim(r1)
  157.     ; You can Add two fault-tolerant in the [], separated by commas
  158.     if RegExMatch(v,"\[([^\]]*)]",r)
  159.     {
  160.       v:=StrReplace(v,r), r1.=","
  161.       StringSplit, r, r1, `,
  162.       e1:=r1, e0:=r2
  163.     }
  164.     StringSplit, r, v, $
  165.     color:=r1, v:=r2
  166.     StringSplit, r, v, .
  167.     w1:=r1, v:=base64tobit(r2), h1:=StrLen(v)//w1
  168.     if (r0<2 or h1<1 or w1>sw or h1>sh or StrLen(v)!=w1*h1)
  169.       Continue
  170.     ;--------------------------------------------
  171.     mode:=InStr(color,"*") ? 1:0
  172.     color:=StrReplace(color,"*") . "@"
  173.     StringSplit, r, color, @
  174.     color:=mode=1 ? r1 : ((r1-1)//w1)*Stride+Mod(r1-1,w1)*4
  175.     n:=Round(r2,2)+(!r2), n:=Floor(255*3*(1-n))
  176.     StrReplace(v,"1","",len1), len0:=StrLen(v)-len1
  177.     VarSetCapacity(allpos, 1024*4, 0), k:=StrLen(v)*4
  178.     VarSetCapacity(s1, k, 0), VarSetCapacity(s0, k, 0)
  179.     ;--------------------------------------------
  180.     if (ok:=PicFind(mode,color,n,Scan0,Stride,sx,sy,sw,sh
  181.       ,v,s1,s0,Round(len1*e1),Round(len0*e0),w1,h1,allpos))
  182.       or (err1=0 and err0=0
  183.       and (ok:=PicFind(mode,color,n,Scan0,Stride,sx,sy,sw,sh
  184.       ,v,s1,s0,Round(len1*0.05),Round(len0*0.05),w1,h1,allpos)))
  185.     {
  186.       Loop, % ok
  187.         pos:=NumGet(allpos, 4*(A_Index-1), "uint")
  188.         , rx:=(pos&0xFFFF)+x, ry:=(pos>>16)+y
  189.         , arr.Push( [rx,ry,w1,h1,comment] )
  190.     }
  191.   }
  192.   SetBatchLines, %bch%
  193.   return, arr.MaxIndex() ? arr:0
  194. }
  195.  
  196. PicFind(mode, color, n, Scan0, Stride, sx, sy, sw, sh
  197.   , ByRef text, ByRef s1, ByRef s0
  198.   , err1, err0, w1, h1, ByRef allpos)
  199. {
  200.   static MyFunc
  201.   if !MyFunc
  202.   {
  203.     x32:="5589E55383EC50C745E8000000008B45242B454083C0018"
  204.     . "945C88B45282B454483C0018945C48B45200FAF45188B551CC"
  205.     . "1E20201D08945C0C745CC000000008B45CC8945D08B45D0894"
  206.     . "5F8C745EC00000000EB78C745F000000000EB638B45EC0FAF4"
  207.     . "5188B55F0C1E20201D08945BC8B45F88D50018955F889C28B4"
  208.     . "52C01D00FB6003C31751C8B45D08D50018955D08D148500000"
  209.     . "0008B453001C28B45BC8902EB1A8B45CC8D50018955CC8D148"
  210.     . "5000000008B453401C28B45BC89028345F0018B45F03B45407"
  211.     . "C958345EC018B45EC3B45447C808B45D03945CC0F4D45CC894"
  212.     . "5B8837D08000F854D020000C745EC00000000E930020000C74"
  213.     . "5F000000000E9140200008B45EC0FAF45188B55F0C1E20201C"
  214.     . "28B45C001D08945F88B45388945D88B453C8945D48B55F88B4"
  215.     . "50C01D08945BC8B45BC83C00289C28B451401D00FB6000FB6C"
  216.     . "08945B48B45BC83C00189C28B451401D00FB6000FB6C08945B"
  217.     . "08B55BC8B451401D00FB6000FB6C08945ACC745F400000000E"
  218.     . "94C0100008B45F43B45D00F8D9A0000008B45F48D148500000"
  219.     . "0008B453001D08B108B45F801D08945BC8B45BC83C00289C28"
  220.     . "B451401D00FB6000FB6C02B45B48945E48B45BC83C00189C28"
  221.     . "B451401D00FB6000FB6C02B45B08945E08B55BC8B451401D00"
  222.     . "FB6000FB6C02B45AC8945DC837DE4007903F75DE4837DE0007"
  223.     . "903F75DE0837DDC007903F75DDC8B55E48B45E001C28B45DC0"
  224.     . "1D03B45107E0E836DD801837DD8000F88EF0000008B45F43B4"
  225.     . "5CC0F8D960000008B45F48D1485000000008B453401D08B108"
  226.     . "B45F801D08945BC8B45BC83C00289C28B451401D00FB6000FB"
  227.     . "6C02B45B48945E48B45BC83C00189C28B451401D00FB6000FB"
  228.     . "6C02B45B08945E08B55BC8B451401D00FB6000FB6C02B45AC8"
  229.     . "945DC837DE4007903F75DE4837DE0007903F75DE0837DDC007"
  230.     . "903F75DDC8B55E48B45E001C28B45DC01D03B45107F0A836DD"
  231.     . "401837DD40078508345F4018B45F43B45B80F8CA8FEFFFF8B4"
  232.     . "5E88D50018955E88D1485000000008B454801D08B4D208B55E"
  233.     . "C01CA89D3C1E3108B4D1C8B55F001CA09DA8910817DE8FF030"
  234.     . "0000F8FFE010000EB0490EB01908345F0018B45F03B45C80F8"
  235.     . "CE0FDFFFF8345EC018B45EC3B45C40F8CC4FDFFFFE9D701000"
  236.     . "08B450C83C00169C0E803000089450CC745EC00000000E98D0"
  237.     . "00000C745F000000000EB788B45EC0FAF45188B55F0C1E2020"
  238.     . "1C28B45C001D08945F88B45F883C00389C28B451401D08B55F"
  239.     . "883C20289D18B551401CA0FB6120FB6D269CA2B0100008B55F"
  240.     . "883C20189D38B551401DA0FB6120FB6D269D24B0200008D1C1"
  241.     . "18B4DF88B551401CA0FB6120FB6D26BD27201DA3B550C0F9CC"
  242.     . "288108345F0018B45F03B45247C808345EC018B45EC3B45280"
  243.     . "F8C67FFFFFF8345C003C745EC00000000E901010000C745F00"
  244.     . "0000000E9E50000008B45EC0FAF45188B55F0C1E20201C28B4"
  245.     . "5C001D08945F88B45388945D88B453C8945D4C745F40000000"
  246.     . "0EB708B45F43B45D07D2E8B45F48D1485000000008B453001D"
  247.     . "08B108B45F801D089C28B451401D00FB6003C01740A836DD80"
  248.     . "1837DD800787B8B45F43B45CC7D2E8B45F48D1485000000008"
  249.     . "B453401D08B108B45F801D089C28B451401D00FB60084C0740"
  250.     . "A836DD401837DD40078488345F4018B45F43B45B87C888B45E"
  251.     . "88D50018955E88D1485000000008B454801D08B4D208B55EC0"
  252.     . "1CA89D3C1E3108B4D1C8B55F001CA09DA8910817DE8FF03000"
  253.     . "07F2BEB0490EB01908345F0018B45F03B45C80F8C0FFFFFFF8"
  254.     . "345EC018B45EC3B45C40F8CF3FEFFFFEB0490EB01908B45E88"
  255.     . "3C4505B5DC244009090"
  256.     x64:="554889E54883EC50894D10895518448945204C894D28C74"
  257.     . "5EC000000008B45482B858000000083C0018945CC8B45502B8"
  258.     . "58800000083C0018945C88B45400FAF45308B5538C1E20201D"
  259.     . "08945C4C745D0000000008B45D08945D48B45D48945FCC745F"
  260.     . "000000000E988000000C745F400000000EB708B45F00FAF453"
  261.     . "08B55F4C1E20201D08945C08B45FC8D50018955FC4863D0488"
  262.     . "B45584801D00FB6003C3175218B45D48D50018955D44898488"
  263.     . "D148500000000488B45604801C28B45C08902EB1F8B45D08D5"
  264.     . "0018955D04898488D148500000000488B45684801C28B45C08"
  265.     . "9028345F4018B45F43B85800000007C858345F0018B45F03B8"
  266.     . "5880000000F8C69FFFFFF8B45D43945D00F4D45D08945BC837"
  267.     . "D10000F8582020000C745F000000000E965020000C745F4000"
  268.     . "00000E9490200008B45F00FAF45308B55F4C1E20201C28B45C"
  269.     . "401D08945FC8B45708945DC8B45788945D88B55FC8B451801D"
  270.     . "08945C08B45C083C0024863D0488B45284801D00FB6000FB6C"
  271.     . "08945B88B45C083C0014863D0488B45284801D00FB6000FB6C"
  272.     . "08945B48B45C04863D0488B45284801D00FB6000FB6C08945B"
  273.     . "0C745F800000000E96C0100008B45F83B45D40F8DAA0000008"
  274.     . "B45F84898488D148500000000488B45604801D08B108B45FC0"
  275.     . "1D08945C08B45C083C0024863D0488B45284801D00FB6000FB"
  276.     . "6C02B45B88945E88B45C083C0014863D0488B45284801D00FB"
  277.     . "6000FB6C02B45B48945E48B45C04863D0488B45284801D00FB"
  278.     . "6000FB6C02B45B08945E0837DE8007903F75DE8837DE400790"
  279.     . "3F75DE4837DE0007903F75DE08B55E88B45E401C28B45E001D"
  280.     . "03B45207E0E836DDC01837DDC000F88090100008B45F83B45D"
  281.     . "00F8DA60000008B45F84898488D148500000000488B4568480"
  282.     . "1D08B108B45FC01D08945C08B45C083C0024863D0488B45284"
  283.     . "801D00FB6000FB6C02B45B88945E88B45C083C0014863D0488"
  284.     . "B45284801D00FB6000FB6C02B45B48945E48B45C04863D0488"
  285.     . "B45284801D00FB6000FB6C02B45B08945E0837DE8007903F75"
  286.     . "DE8837DE4007903F75DE4837DE0007903F75DE08B55E88B45E"
  287.     . "401C28B45E001D03B45207F0A836DD801837DD800785A8345F"
  288.     . "8018B45F83B45BC0F8C88FEFFFF8B45EC8D50018955EC48984"
  289.     . "88D148500000000488B85900000004801D08B4D408B55F001C"
  290.     . "AC1E2104189D08B4D388B55F401CA4409C28910817DECFF030"
  291.     . "0000F8F3A020000EB0490EB01908345F4018B45F43B45CC0F8"
  292.     . "CABFDFFFF8345F0018B45F03B45C80F8C8FFDFFFFE91302000"
  293.     . "08B451883C00169C0E8030000894518C745F000000000E9A40"
  294.     . "00000C745F400000000E9880000008B45F00FAF45308B55F4C"
  295.     . "1E20201C28B45C401D08945FC8B45FC83C0034863D0488B452"
  296.     . "84801D08B55FC83C2024863CA488B55284801CA0FB6120FB6D"
  297.     . "269CA2B0100008B55FC83C2014C63C2488B55284C01C20FB61"
  298.     . "20FB6D269D24B020000448D04118B55FC4863CA488B5528480"
  299.     . "1CA0FB6120FB6D26BD2724401C23B55180F9CC288108345F40"
  300.     . "18B45F43B45480F8C6CFFFFFF8345F0018B45F03B45500F8C5"
  301.     . "0FFFFFF8345C403C745F000000000E926010000C745F400000"
  302.     . "000E90A0100008B45F00FAF45308B55F4C1E20201C28B45C40"
  303.     . "1D08945FC8B45708945DC8B45788945D8C745F800000000E98"
  304.     . "40000008B45F83B45D47D3A8B45F84898488D1485000000004"
  305.     . "88B45604801D08B108B45FC01D04863D0488B45284801D00FB"
  306.     . "6003C01740E836DDC01837DDC000F88910000008B45F83B45D"
  307.     . "07D368B45F84898488D148500000000488B45684801D08B108"
  308.     . "B45FC01D04863D0488B45284801D00FB60084C0740A836DD80"
  309.     . "1837DD80078568345F8018B45F83B45BC0F8C70FFFFFF8B45E"
  310.     . "C8D50018955EC4898488D148500000000488B8590000000480"
  311.     . "1D08B4D408B55F001CAC1E2104189D08B4D388B55F401CA440"
  312.     . "9C28910817DECFF0300007F2BEB0490EB01908345F4018B45F"
  313.     . "43B45CC0F8CEAFEFFFF8345F0018B45F03B45C80F8CCEFEFFF"
  314.     . "FEB0490EB01908B45EC4883C4505DC39090909090909090"
  315.     MCode(MyFunc, A_PtrSize=8 ? x64:x32)
  316.   }
  317.   return, DllCall(&MyFunc, "int",mode
  318.     , "uint",color, "int",n, "ptr",Scan0, "int",Stride
  319.     , "int",sx, "int",sy, "int",sw, "int",sh
  320.     , "AStr",text, "ptr",&s1, "ptr",&s0
  321.     , "int",err1, "int",err0, "int",w1, "int",h1, "ptr",&allpos)
  322. }
  323.  
  324. xywh2xywh(x1,y1,w1,h1,ByRef x,ByRef y,ByRef w,ByRef h)
  325. {
  326.   SysGet, zx, 76
  327.   SysGet, zy, 77
  328.   SysGet, zw, 78
  329.   SysGet, zh, 79
  330.   left:=x1, right:=x1+w1-1, up:=y1, down:=y1+h1-1
  331.   left:=left<zx ? zx:left, right:=right>zx+zw-1 ? zx+zw-1:right
  332.   up:=up<zy ? zy:up, down:=down>zy+zh-1 ? zy+zh-1:down
  333.   x:=left, y:=up, w:=right-left+1, h:=down-up+1
  334. }
  335.  
  336. GetBitsFromScreen(x,y,w,h,ByRef Scan0,ByRef Stride,ByRef bits)
  337. {
  338.   VarSetCapacity(bits,w*h*4,0), bpp:=32
  339.   Scan0:=&bits, Stride:=((w*bpp+31)//32)*4
  340.   Ptr:=A_PtrSize ? "UPtr" : "UInt", PtrP:=Ptr . "*"
  341.   win:=DllCall("GetDesktopWindow", Ptr)
  342.   hDC:=DllCall("GetWindowDC", Ptr,win, Ptr)
  343.   mDC:=DllCall("CreateCompatibleDC", Ptr,hDC, Ptr)
  344.   ;-------------------------
  345.   VarSetCapacity(bi, 40, 0), NumPut(40, bi, 0, "int")
  346.   NumPut(w, bi, 4, "int"), NumPut(-h, bi, 8, "int")
  347.   NumPut(1, bi, 12, "short"), NumPut(bpp, bi, 14, "short")
  348.   ;-------------------------
  349.   if hBM:=DllCall("CreateDIBSection", Ptr,mDC, Ptr,&bi
  350.     , "int",0, PtrP,ppvBits, Ptr,0, "int",0, Ptr)
  351.   {
  352.     oBM:=DllCall("SelectObject", Ptr,mDC, Ptr,hBM, Ptr)
  353.     DllCall("BitBlt", Ptr,mDC, "int",0, "int",0, "int",w, "int",h
  354.       , Ptr,hDC, "int",x, "int",y, "uint",0x00CC0020|0x40000000)
  355.     DllCall("RtlMoveMemory", Ptr,Scan0, Ptr,ppvBits, Ptr,Stride*h)
  356.     DllCall("SelectObject", Ptr,mDC, Ptr,oBM)
  357.     DllCall("DeleteObject", Ptr,hBM)
  358.   }
  359.   DllCall("DeleteDC", Ptr,mDC)
  360.   DllCall("ReleaseDC", Ptr,win, Ptr,hDC)
  361. }
  362.  
  363. MCode(ByRef code, hex)
  364. {
  365.   ListLines, Off
  366.   bch:=A_BatchLines
  367.   SetBatchLines, -1
  368.   VarSetCapacity(code, StrLen(hex)//2)
  369.   Loop, % StrLen(hex)//2
  370.     NumPut("0x" . SubStr(hex,2*A_Index-1,2),code,A_Index-1,"uchar")
  371.   Ptr:=A_PtrSize ? "UPtr" : "UInt"
  372.   DllCall("VirtualProtect", Ptr,&code, Ptr
  373.     ,VarSetCapacity(code), "uint",0x40, Ptr . "*",0)
  374.   SetBatchLines, %bch%
  375.   ListLines, On
  376. }
  377.  
  378. base64tobit(s)
  379. {
  380.   ListLines, Off
  381.   Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  382.     . "abcdefghijklmnopqrstuvwxyz"
  383.   SetFormat, IntegerFast, d
  384.   StringCaseSense, On
  385.   Loop, Parse, Chars
  386.   {
  387.     i:=A_Index-1, v:=(i>>5&1) . (i>>4&1)
  388.       . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)
  389.     s:=StrReplace(s,A_LoopField,v)
  390.   }
  391.   StringCaseSense, Off
  392.   s:=SubStr(s,1,InStr(s,"1",0,0)-1)
  393.   s:=RegExReplace(s,"[^01]+")
  394.   ListLines, On
  395.   return, s
  396. }
  397.  
  398. bit2base64(s)
  399. {
  400.   ListLines, Off
  401.   s:=RegExReplace(s,"[^01]+")
  402.   s.=SubStr("100000",1,6-Mod(StrLen(s),6))
  403.   s:=RegExReplace(s,".{6}","|$0")
  404.   Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  405.     . "abcdefghijklmnopqrstuvwxyz"
  406.   SetFormat, IntegerFast, d
  407.   Loop, Parse, Chars
  408.   {
  409.     i:=A_Index-1, v:="|" . (i>>5&1) . (i>>4&1)
  410.       . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)
  411.     s:=StrReplace(s,v,A_LoopField)
  412.   }
  413.   ListLines, On
  414.   return, s
  415. }
  416.  
  417. ASCII(s)
  418. {
  419.   if RegExMatch(s,"\$(\d+)\.([\w+/]+)",r)
  420.   {
  421.     s:=RegExReplace(base64tobit(r2),".{" r1 "}","$0`n")
  422.     s:=StrReplace(StrReplace(s,"0","_"),"1","0")
  423.   }
  424.   else s=
  425.   return, s
  426. }
  427.  
  428. ; You can put the text library at the beginning of the script,
  429. ; and Use Pic(Text,1) to add the text library to Pic()'s Lib,
  430. ; Use Pic("comment1|comment2|...") to get text images from Lib
  431.  
  432. Pic(comments, add_to_Lib=0)
  433. {
  434.   static Lib:=[]
  435.   if (add_to_Lib)
  436.   {
  437.     re:="<([^>]*)>[^$]+\$\d+\.[\w+/]{3,}"
  438.     Loop, Parse, comments, |
  439.       if RegExMatch(A_LoopField,re,r)
  440.         Lib[Trim(r1)]:=r
  441.     Lib[""]:=""
  442.   }
  443.   else
  444.   {
  445.     text:=""
  446.     Loop, Parse, comments, |
  447.       text.="|" . Lib[Trim(A_LoopField)]
  448.     return, text
  449.   }
  450. }
  451.  
  452. PicN(number)
  453. {
  454.   return, Pic(Trim(RegExReplace(number,".","$0|"),"|"))
  455. }
  456.  
  457. FindTextOCR(nX, nY, nW, nH, err1, err0, Text, Interval=5)
  458. {
  459.   OCR:="", Right_X:=nX+nW
  460.   While (ok:=FindText(nX, nY, nW, nH, err1, err0, Text))
  461.   {
  462.     ; For multi text search, This is the number of text images found
  463.     Loop, % ok.MaxIndex()
  464.     {
  465.       ; X is the X coordinates of the upper left corner
  466.       ; and W is the width of the image have been found
  467.       i:=A_Index, x:=ok[i].1, y:=ok[i].2
  468.         , w:=ok[i].3, h:=ok[i].4, comment:=ok[i].5
  469.       ; We need the leftmost X coordinates
  470.       if (A_Index=1 or x<Left_X)
  471.         Left_X:=x, Left_W:=w, Left_OCR:=comment
  472.     }
  473.     ; If the interval exceeds the set value, add "*" to the result
  474.     OCR.=(A_Index>1 and Left_X-Last_X>Interval ? "*":"") . Left_OCR
  475.     ; Update nX and nW for next search
  476.     x:=Left_X+Left_W, nW:=(Right_X-x)//2, nX:=x+nW, Last_X:=x
  477.   }
  478.   Return, OCR
  479. }
  480.  
  481.  
  482. /***** C source code of machine code *****
  483.  
  484. int __attribute__((__stdcall__)) PicFind(
  485.   int mode, int c, int n, unsigned char * Bmp
  486.   , int Stride, int sx, int sy, int sw, int sh
  487.   , char * text, int * s1, int * s0
  488.   , int err1, int err0, int w1, int h1, int * allpos)
  489. {
  490.   int o, i, j, k, x, y, w, h, ok=0;
  491.   int r, g, b, rr, gg, bb, e1, e0, len1, len0, max;
  492.   w=sw-w1+1; h=sh-h1+1; k=sy*Stride+sx*4;
  493.   // Generate Lookup Table
  494.   o=len1=len0=0;
  495.   for (y=0; y<h1; y++)
  496.   {
  497.     for (x=0; x<w1; x++)
  498.     {
  499.       j=y*Stride+x*4;
  500.       if (text[o++]=='1')
  501.         s1[len1++]=j;
  502.       else
  503.         s0[len0++]=j;
  504.     }
  505.   }
  506.   max=len1>len0 ? len1 : len0;
  507.   // Color Mode
  508.   if (mode==0)
  509.   {
  510.     for (y=0; y<h; y++)
  511.     {
  512.       for (x=0; x<w; x++)
  513.       {
  514.         o=y*Stride+x*4+k; e1=err1; e0=err0;
  515.         j=o+c; rr=Bmp[2+j]; gg=Bmp[1+j]; bb=Bmp[j];
  516.         for (i=0; i<max; i++)
  517.         {
  518.           if (i<len1)
  519.           {
  520.             j=o+s1[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb;
  521.             if (r<0) r=-r; if (g<0) g=-g; if (b<0) b=-b;
  522.             if (r+g+b>n && (--e1)<0) goto NoMatch1;
  523.           }
  524.           if (i<len0)
  525.           {
  526.             j=o+s0[i]; r=Bmp[2+j]-rr; g=Bmp[1+j]-gg; b=Bmp[j]-bb;
  527.             if (r<0) r=-r; if (g<0) g=-g; if (b<0) b=-b;
  528.             if (r+g+b<=n && (--e0)<0) goto NoMatch1;
  529.           }
  530.         }
  531.         allpos[ok++]=(sy+y)<<16|(sx+x);
  532.         if (ok>=1024) goto Return1;
  533.         NoMatch1:
  534.         continue;
  535.       }
  536.     }
  537.     goto Return1;
  538.   }
  539.   // Gray Threshold Mode
  540.   c=(c+1)*1000;
  541.   for (y=0; y<sh; y++)
  542.   {
  543.     for (x=0; x<sw; x++)
  544.     {
  545.       o=y*Stride+x*4+k;
  546.       Bmp[3+o]=Bmp[2+o]*299+Bmp[1+o]*587+Bmp[o]*114<c ? 1:0;
  547.     }
  548.   }
  549.   k=k+3;
  550.   for (y=0; y<h; y++)
  551.   {
  552.     for (x=0; x<w; x++)
  553.     {
  554.       o=y*Stride+x*4+k; e1=err1; e0=err0;
  555.       for (i=0; i<max; i++)
  556.       {
  557.         if (i<len1 && Bmp[o+s1[i]]!=1 && (--e1)<0) goto NoMatch2;
  558.         if (i<len0 && Bmp[o+s0[i]]!=0 && (--e0)<0) goto NoMatch2;
  559.       }
  560.       allpos[ok++]=(sy+y)<<16|(sx+x);
  561.       if (ok>=1024) goto Return1;
  562.       NoMatch2:
  563.       continue;
  564.     }
  565.   }
  566.   Return1:
  567.   return ok;
  568. }
  569.  
  570. */
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement