无忧启动论坛

标题: 版主,寨主培训班(从0教你打造一键式扣分精灵) [打印本页]

作者: tt911    时间: 2017-10-23 11:54
标题: 版主,寨主培训班(从0教你打造一键式扣分精灵)
本帖最后由 tt911 于 2017-10-23 12:00 编辑

第一步,我们找个流氓贴子,作为扣分对象
譬如这个
http://bbs.wuyou.net/forum.php?mod=viewthread&tid=402851
好了,坏蛋有了,我们就可以使用工具来快速的写代码了

第二步,点击字库制作工具
点击抓取文字 按钮

之后目标对象上 移动鼠标几像素!


我们点击, 左删 右删 上删 下删,总之不大不小就可以啦~~

点击配图上面的那几个地方,最后点插入

替换掉代码中的★
高人做的字库系统.rar (11.75 KB, 下载次数: 0)

这种方法只要一个AHK脚本文件就可以了,而不必使用外部的图片文件。

F11::                         ;这里是自己设置的热键,发现论坛上的狗皮膏药时,按热键就可以自动化的扣分了。

文字=
文字.="|<>14.20lUMMCA723UVk0/zszy0008"
if 查找文字(1100,806,150000,150000,文字,"*138",X,Y,OCR,0,0)
{
  CoordMode, Mouse
  MouseMove, X, Y
  Click X, Y
  sleep , 500
  send , -5{Del}                ;这里是实际我们测试通过要加入的代码 -5 之后,删除后边的那个0
  send , {Enter}
}
return


  1. ;---- 将后面的函数附加到自己的脚本中 ----
  2. ;-----------------------------------------
  3. ; 查找屏幕文字/图像字库及OCR识别
  4. ; 注意:参数中的x、y为中心点坐标,w、h为左右上下偏移
  5. ; cha1、cha0分别为0、_字符的容许减少百分比
  6. ;-----------------------------------------
  7. 查找文字(x,y,w,h,wz,c,ByRef rx="",ByRef ry="",ByRef ocr=""
  8.   , cha1=0, cha0=0)
  9. {
  10.   xywh2xywh(x-w,y-h,2*w+1,2*h+1,x,y,w,h)
  11.   if (w<1 or h<1)
  12.     Return, 0
  13.   bch:=A_BatchLines
  14.   SetBatchLines, -1
  15.   ;--------------------------------------
  16.   GetBitsFromScreen(x,y,w,h,Scan0,Stride,bits)
  17.   ;--------------------------------------
  18.   ; 设定图内查找范围,注意不要越界
  19.   sx:=0, sy:=0, sw:=w, sh:=h
  20.   if PicOCR(Scan0,Stride,sx,sy,sw,sh,wz,c
  21.     ,rx,ry,ocr,cha1,cha0)
  22.   {
  23.     rx+=x, ry+=y
  24.     SetBatchLines, %bch%
  25.     Return, 1
  26.   }
  27.   ; 容差为0的若失败则使用 5% 的容差再找一次
  28.   if (cha1=0 and cha0=0)
  29.     and PicOCR(Scan0,Stride,sx,sy,sw,sh,wz,c
  30.       ,rx,ry,ocr,0.05,0.05)
  31.   {
  32.     rx+=x, ry+=y
  33.     SetBatchLines, %bch%
  34.     Return, 1
  35.   }
  36.   SetBatchLines, %bch%
  37.   Return, 0
  38. }

  39. ;-- 规范输入范围在屏幕范围内
  40. xywh2xywh(x1,y1,w1,h1,ByRef x,ByRef y,ByRef w,ByRef h)
  41. {
  42.   ; 获取包含所有显示器的虚拟屏幕范围
  43.   SysGet, zx, 76
  44.   SysGet, zy, 77
  45.   SysGet, zw, 78
  46.   SysGet, zh, 79
  47.   left:=x1, right:=x1+w1-1, up:=y1, down:=y1+h1-1
  48.   left:=left<zx ? zx:left, right:=right>zx+zw-1 ? zx+zw-1:right
  49.   up:=up<zy ? zy:up, down:=down>zy+zh-1 ? zy+zh-1:down
  50.   x:=left, y:=up, w:=right-left+1, h:=down-up+1
  51. }

  52. ;-- 获取屏幕图像的内存数据,图像包括透明窗口
  53. GetBitsFromScreen(x,y,w,h,ByRef Scan0,ByRef Stride,ByRef bits)
  54. {
  55.   VarSetCapacity(bits, w*h*4, 0)
  56.   Ptr:=A_PtrSize ? "Ptr" : "UInt"
  57.   ; 桌面窗口对应包含所有显示器的虚拟屏幕
  58.   win:=DllCall("GetDesktopWindow", Ptr)
  59.   hDC:=DllCall("GetWindowDC", Ptr,win, Ptr)
  60.   mDC:=DllCall("CreateCompatibleDC", Ptr,hDC, Ptr)
  61.   hBM:=DllCall("CreateCompatibleBitmap", Ptr,hDC
  62.     , "int",w, "int",h, Ptr)
  63.   oBM:=DllCall("SelectObject", Ptr,mDC, Ptr,hBM, Ptr)
  64.   DllCall("BitBlt", Ptr,mDC, "int",0, "int",0, "int",w, "int",h
  65.     , Ptr,hDC, "int",x, "int",y, "uint",0x00CC0020|0x40000000)
  66.   ;--------------------------
  67.   VarSetCapacity(bi, 40, 0)
  68.   NumPut(40, bi, 0, "int"), NumPut(w, bi, 4, "int")
  69.   NumPut(-h, bi, 8, "int"), NumPut(1, bi, 12, "short")
  70.   NumPut(bpp:=32, bi, 14, "short"), NumPut(0, bi, 16, "int")
  71.   ;--------------------------
  72.   DllCall("GetDIBits", Ptr,mDC, Ptr,hBM
  73.     , "int",0, "int",h, Ptr,&bits, Ptr,&bi, "int",0)
  74.   DllCall("SelectObject", Ptr,mDC, Ptr,oBM)
  75.   DllCall("DeleteObject", Ptr,hBM)
  76.   DllCall("DeleteDC", Ptr,mDC)
  77.   DllCall("ReleaseDC", Ptr,win, Ptr,hDC)
  78.   Scan0:=&bits, Stride:=((w*bpp+31)//32)*4
  79. }

  80. ;-----------------------------------------
  81. ; 图像内查找文字/图像字符串及OCR函数
  82. ;-----------------------------------------
  83. PicOCR(Scan0, Stride, sx, sy, sw, sh, wenzi, c
  84.   , ByRef rx, ByRef ry, ByRef ocr, cha1, cha0)
  85. {
  86.   static MyFunc
  87.   if !MyFunc
  88.   {
  89.     x32:="5589E55383EC608B45200FAF45188B551CC1E20201D0894"
  90.     . "5F08B5524B80000000029D0C1E00289C28B451801D08945ECC"
  91.     . "745E800000000C745D400000000C745D0000000008B4524894"
  92.     . "5CC8B45288945C8C745C400000000837D08000F85B20000008"
  93.     . "B450CC1E81025FF0000008945C08B450CC1E80825FF0000008"
  94.     . "945BC8B450C25FF0000008945B8C745F400000000EB75C745F"
  95.     . "800000000EB5A8B45F083C00289C28B451401D00FB6000FB6C"
  96.     . "03B45C075368B45F083C00189C28B451401D00FB6000FB6C03"
  97.     . "B45BC751E8B55F08B451401D00FB6000FB6C03B45B8750B8B5"
  98.     . "5E88B453001D0C600318345F8018345F0048345E8018B45F83"
  99.     . "B45247C9E8345F4018B45EC0145F08B45F43B45287C83E9170"
  100.     . "20000837D08010F85A30000008B450C83C001C1E00789450CC"
  101.     . "745F400000000EB7DC745F800000000EB628B45F083C00289C"
  102.     . "28B451401D00FB6000FB6C06BD0268B45F083C00189C18B451"
  103.     . "401C80FB6000FB6C06BC04B8D0C028B55F08B451401D00FB60"
  104.     . "00FB6D089D0C1E00429D001C83B450C730B8B55E88B453001D"
  105.     . "0C600318345F8018345F0048345E8018B45F83B45247C96834"
  106.     . "5F4018B45EC0145F08B45F43B45280F8C77FFFFFFE96A01000"
  107.     . "0C745F400000000EB7BC745F800000000EB608B55E88B452C8"
  108.     . "D0C028B45F083C00289C28B451401D00FB6000FB6C06BD0268"
  109.     . "B45F083C00189C38B451401D80FB6000FB6C06BC04B8D1C028"
  110.     . "B55F08B451401D00FB6000FB6D089D0C1E00429D001D8C1F80"
  111.     . "788018345F8018345F0048345E8018B45F83B45247C988345F"
  112.     . "4018B45EC0145F08B45F43B45280F8C79FFFFFF8B452483E80"
  113.     . "18945B48B452883E8018945B0C745F401000000E9B0000000C"
  114.     . "745F801000000E9940000008B45F40FAF452489C28B45F801D"
  115.     . "08945E88B55E88B452C01D00FB6000FB6D08B450C01D08945E"
  116.     . "C8B45E88D50FF8B452C01D00FB6000FB6C03B45EC7F488B45E"
  117.     . "88D50018B452C01D00FB6000FB6C03B45EC7F328B45E82B452"
  118.     . "489C28B452C01D00FB6000FB6C03B45EC7F1A8B55E88B45240"
  119.     . "1D089C28B452C01D00FB6000FB6C03B45EC7E0B8B55E88B453"
  120.     . "001D0C600318345F8018B45F83B45B40F8C60FFFFFF8345F40"
  121.     . "18B45F43B45B00F8C44FFFFFFC745E800000000E9E30000008"
  122.     . "B45E88D1485000000008B454001D08B008945E08B45E08945E"
  123.     . "48B45E48945F08B45E883C0018D1485000000008B454001D08"
  124.     . "B008945B48B45E883C0028D1485000000008B454001D08B008"
  125.     . "945B0C745F400000000EB7CC745F800000000EB678B45F08D5"
  126.     . "0018955F089C28B453401D00FB6003C3175278B45E48D50018"
  127.     . "955E48D1485000000008B453801C28B45F40FAF452489C18B4"
  128.     . "5F801C88902EB258B45E08D50018955E08D1485000000008B4"
  129.     . "53C01C28B45F40FAF452489C18B45F801C889028345F8018B4"
  130.     . "5F83B45B47C918345F4018B45F43B45B00F8C78FFFFFF8345E"
  131.     . "8078B45E83B45440F8C11FFFFFF8B45D00FAF452489C28B45D"
  132.     . "401D08945F08B45240FAF45C8BA0100000029C289D08945E4C"
  133.     . "745F800000000E9B5020000C745F400000000E993020000C74"
  134.     . "5E800000000E9710200008B45E883C0018D1485000000008B4"
  135.     . "54001D08B008945B48B45E883C0028D1485000000008B45400"
  136.     . "1D08B008945B08B55F88B45B401D03B45CC0F8F2D0200008B5"
  137.     . "5F48B45B001D03B45C80F8F1C0200008B45E88D14850000000"
  138.     . "08B454001D08B008945E08B45E883C0038D1485000000008B4"
  139.     . "54001D08B008945AC8B45E883C0048D1485000000008B45400"
  140.     . "1D08B008945A88B45E883C0058D1485000000008B454001D08"
  141.     . "B008945DC8B45E883C0068D1485000000008B454001D08B008"
  142.     . "945D88B45AC3945A80F4D45A88945A4C745EC00000000E9820"
  143.     . "000008B45EC3B45AC7D378B55E08B45EC01D08D14850000000"
  144.     . "08B453801D08B108B45F001D089C28B453001D00FB6003C317"
  145.     . "40E836DDC01837DDC000F884E0100008B45EC3B45A87D378B5"
  146.     . "5E08B45EC01D08D1485000000008B453C01D08B108B45F001D"
  147.     . "089C28B453001D00FB6003C30740E836DD801837DD8000F881"
  148.     . "20100008345EC018B45EC3B45A40F8C72FFFFFF837DC4000F8"
  149.     . "5840000008B551C8B45F801C28B454889108B454883C0048B4"
  150.     . "D208B55F401CA89108B45488D50088B45B489028B45488D500"
  151.     . "C8B45B08902C745C4040000008B45F42B45B08945D08B55B08"
  152.     . "9D001C001D08945C88B55B089D0C1E00201D001C083C064894"
  153.     . "5CC837DD0007907C745D0000000008B45282B45D03B45C87D2"
  154.     . "E8B45282B45D08945C8EB238B45F83B45107E1B8B45C48D500"
  155.     . "18955C48D1485000000008B454801D0C700FFFFFFFF8B45C48"
  156.     . "D50018955C48D1485000000008B454801D08B55E883C207891"
  157.     . "0817DC4FD0300007F788B55F88B45B401D00145D48B45242B4"
  158.     . "5D43B45CC0F8D60FDFFFF8B45242B45D48945CCE952FDFFFF9"
  159.     . "0EB0490EB01908345E8078B45E83B45440F8C83FDFFFF8345F"
  160.     . "4018B45240145F08B45F43B45C80F8C61FDFFFF8345F8018B4"
  161.     . "5E40145F08B45F83B45CC0F8C3FFDFFFF837DC4007508B8000"
  162.     . "00000EB1B908B45C48D1485000000008B454801D0C70000000"
  163.     . "000B80100000083C4605B5DC2440090"
  164.     x64:="554889E54883EC60894D10895518448945204C894D288B4"
  165.     . "5400FAF45308B5538C1E20201D08945F48B5548B8000000002"
  166.     . "9D0C1E00289C28B453001D08945F0C745EC00000000C745D80"
  167.     . "0000000C745D4000000008B45488945D08B45508945CCC745C"
  168.     . "800000000837D10000F85C90000008B4518C1E81025FF00000"
  169.     . "08945C48B4518C1E80825FF0000008945C08B451825FF00000"
  170.     . "08945BCC745F800000000E985000000C745FC00000000EB6A8"
  171.     . "B45F483C0024863D0488B45284801D00FB6000FB6C03B45C47"
  172.     . "5438B45F483C0014863D0488B45284801D00FB6000FB6C03B4"
  173.     . "5C075288B45F44863D0488B45284801D00FB6000FB6C03B45B"
  174.     . "C75108B45EC4863D0488B45604801D0C600318345FC018345F"
  175.     . "4048345EC018B45FC3B45487C8E8345F8018B45F00145F48B4"
  176.     . "5F83B45500F8C6FFFFFFFE959020000837D10010F85B600000"
  177.     . "08B451883C001C1E007894518C745F800000000E98D000000C"
  178.     . "745FC00000000EB728B45F483C0024863D0488B45284801D00"
  179.     . "FB6000FB6C06BD0268B45F483C0014863C8488B45284801C80"
  180.     . "FB6000FB6C06BC04B8D0C028B45F44863D0488B45284801D00"
  181.     . "FB6000FB6D089D0C1E00429D001C83B451873108B45EC4863D"
  182.     . "0488B45604801D0C600318345FC018345F4048345EC018B45F"
  183.     . "C3B45487C868345F8018B45F00145F48B45F83B45500F8C67F"
  184.     . "FFFFFE999010000C745F800000000E98D000000C745FC00000"
  185.     . "000EB728B45EC4863D0488B4558488D0C028B45F483C002486"
  186.     . "3D0488B45284801D00FB6000FB6C06BD0268B45F483C0014C6"
  187.     . "3C0488B45284C01C00FB6000FB6C06BC04B448D04028B45F44"
  188.     . "863D0488B45284801D00FB6000FB6D089D0C1E00429D04401C"
  189.     . "0C1F80788018345FC018345F4048345EC018B45FC3B45487C8"
  190.     . "68345F8018B45F00145F48B45F83B45500F8C67FFFFFF8B454"
  191.     . "883E8018945B88B455083E8018945B4C745F801000000E9CA0"
  192.     . "00000C745FC01000000E9AE0000008B45F80FAF454889C28B4"
  193.     . "5FC01D08945EC8B45EC4863D0488B45584801D00FB6000FB6D"
  194.     . "08B451801D08945F08B45EC4898488D50FF488B45584801D00"
  195.     . "FB6000FB6C03B45F07F538B45EC4898488D5001488B4558480"
  196.     . "1D00FB6000FB6C03B45F07F388B45EC2B45484863D0488B455"
  197.     . "84801D00FB6000FB6C03B45F07F1D8B55EC8B454801D04863D"
  198.     . "0488B45584801D00FB6000FB6C03B45F07E108B45EC4863D04"
  199.     . "88B45604801D0C600318345FC018B45FC3B45B80F8C46FFFFF"
  200.     . "F8345F8018B45F83B45B40F8C2AFFFFFFC745EC00000000E90"
  201.     . "D0100008B45EC4898488D148500000000488B8580000000480"
  202.     . "1D08B008945E48B45E48945E88B45E88945F48B45EC4898488"
  203.     . "3C001488D148500000000488B85800000004801D08B008945B"
  204.     . "88B45EC48984883C002488D148500000000488B85800000004"
  205.     . "801D08B008945B4C745F800000000E989000000C745FC00000"
  206.     . "000EB748B45F48D50018955F44863D0488B45684801D00FB60"
  207.     . "03C31752C8B45E88D50018955E84898488D148500000000488"
  208.     . "B45704801C28B45F80FAF454889C18B45FC01C88902EB2A8B4"
  209.     . "5E48D50018955E44898488D148500000000488B45784801C28"
  210.     . "B45F80FAF454889C18B45FC01C889028345FC018B45FC3B45B"
  211.     . "87C848345F8018B45F83B45B40F8C6BFFFFFF8345EC078B45E"
  212.     . "C3B85880000000F8CE4FEFFFF8B45D40FAF454889C28B45D80"
  213.     . "1D08945F48B45480FAF45CCBA0100000029C289D08945E8C74"
  214.     . "5FC00000000E929030000C745F800000000E907030000C745E"
  215.     . "C00000000E9E20200008B45EC48984883C001488D148500000"
  216.     . "000488B85800000004801D08B008945B88B45EC48984883C00"
  217.     . "2488D148500000000488B85800000004801D08B008945B48B5"
  218.     . "5FC8B45B801D03B45D00F8F8C0200008B55F88B45B401D03B4"
  219.     . "5CC0F8F7B0200008B45EC4898488D148500000000488B85800"
  220.     . "000004801D08B008945E48B45EC48984883C003488D1485000"
  221.     . "00000488B85800000004801D08B008945B08B45EC48984883C"
  222.     . "004488D148500000000488B85800000004801D08B008945AC8"
  223.     . "B45EC48984883C005488D148500000000488B8580000000480"
  224.     . "1D08B008945E08B45EC48984883C006488D148500000000488"
  225.     . "B85800000004801D08B008945DC8B45B03945AC0F4D45AC894"
  226.     . "5A8C745F000000000E9920000008B45F03B45B07D3F8B55E48"
  227.     . "B45F001D04898488D148500000000488B45704801D08B108B4"
  228.     . "5F401D04863D0488B45604801D00FB6003C31740E836DE0018"
  229.     . "37DE0000F88790100008B45F03B45AC7D3F8B55E48B45F001D"
  230.     . "04898488D148500000000488B45784801D08B108B45F401D04"
  231.     . "863D0488B45604801D00FB6003C30740E836DDC01837DDC000"
  232.     . "F88350100008345F0018B45F03B45A80F8C62FFFFFF837DC80"
  233.     . "00F85970000008B55388B45FC01C2488B85900000008910488"
  234.     . "B85900000004883C0048B4D408B55F801CA8910488B8590000"
  235.     . "000488D50088B45B88902488B8590000000488D500C8B45B48"
  236.     . "902C745C8040000008B45F82B45B48945D48B55B489D001C00"
  237.     . "1D08945CC8B55B489D0C1E00201D001C083C0648945D0837DD"
  238.     . "4007907C745D4000000008B45502B45D43B45CC7D368B45502"
  239.     . "B45D48945CCEB2B8B45FC3B45207E238B45C88D50018955C84"
  240.     . "898488D148500000000488B85900000004801D0C700FFFFFFF"
  241.     . "F8B45C88D50018955C84898488D148500000000488B8590000"
  242.     . "0004801D08B55EC83C2078910817DC8FD0300007F7B8B55FC8"
  243.     . "B45B801D00145D88B45482B45D83B45D00F8DEFFCFFFF8B454"
  244.     . "82B45D88945D0E9E1FCFFFF90EB0490EB01908345EC078B45E"
  245.     . "C3B85880000000F8C0FFDFFFF8345F8018B45480145F48B45F"
  246.     . "83B45CC0F8CEDFCFFFF8345FC018B45E80145F48B45FC3B45D"
  247.     . "00F8CCBFCFFFF837DC8007508B800000000EB23908B45C8489"
  248.     . "8488D148500000000488B85900000004801D0C70000000000B"
  249.     . "8010000004883C4605DC390909090909090909090"
  250.     MCode(MyFunc, A_PtrSize=8 ? x64:x32)
  251.   }
  252.   ;--------------------------------------
  253.   ; 统计字库文字的个数和宽高,将解释文字存入数组并删除<>
  254.   ;--------------------------------------
  255.   wenzitab:=[], num:=0, wz:="", j:=""
  256.   Loop, Parse, wenzi, |
  257.   {
  258.     v:=A_LoopField, txt:="", e1:=cha1, e0:=cha0
  259.     ; 用角括号输入每个字库字符串的识别结果文字
  260.     if RegExMatch(v,"<([^>]*)>",r)
  261.       v:=StrReplace(v,r), txt:=r1
  262.     ; 可以用中括号输入每个文字的两个容差,以逗号分隔
  263.     if RegExMatch(v,"\[([^\]]*)]",r)
  264.     {
  265.       v:=StrReplace(v,r), r2:=""
  266.       StringSplit, r, r1, `,
  267.       e1:=r1, e0:=r2
  268.     }
  269.     ; 记录每个文字的起始位置、宽、高、10字符的数量和容差
  270.     StringSplit, r, v, .
  271.     w:=r1, v:=base64tobit(r2), h:=StrLen(v)//w
  272.     if (r0<2 or w>sw or h>sh or StrLen(v)!=w*h)
  273.       Continue
  274.     if InStr(c,"-")
  275.     {
  276.       r:=e1, e1:=e0, e0:=r, v:=StrReplace(v,"1","_")
  277.       v:=StrReplace(StrReplace(v,"0","1"),"_","0")
  278.     }
  279.     len1:=StrLen(StrReplace(v,"0"))
  280.     len0:=StrLen(StrReplace(v,"1"))
  281.     e1:=Round(len1*e1), e0:=Round(len0*e0)
  282.     j.=StrLen(wz) "|" w "|" h
  283.       . "|" len1 "|" len0 "|" e1 "|" e0 "|"
  284.     wz.=v, wenzitab[++num]:=Trim(txt)
  285.   }
  286.   IfEqual, wz,, Return, 0
  287.   ;--------------------------------------
  288.   ; wz 使用Astr参数类型可以自动转为ANSI版字符串
  289.   ; in 输入各文字的起始位置等信息,out 返回结果
  290.   ; ss 等为临时内存,jiange 超过间隔就会加入*号
  291.   ;--------------------------------------
  292.   mode:=InStr(c,"**") ? 2 : InStr(c,"*") ? 1 : 0
  293.   c:=RegExReplace(c,"[*\-]"), jiange:=5, num*=7
  294.   VarSetCapacity(in,num*4,0), i:=-4
  295.   Loop, Parse, j, |
  296.     if (A_Index<=num)
  297.       NumPut(A_LoopField, in, i+=4, "int")
  298.   VarSetCapacity(gs, sw*sh)
  299.   VarSetCapacity(ss, sw*sh, Asc("0"))
  300.   k:=StrLen(wz)*4
  301.   VarSetCapacity(s1, k, 0), VarSetCapacity(s0, k, 0)
  302.   VarSetCapacity(out, 1024*4, 0)
  303.   if DllCall(&MyFunc, "int",mode, "uint",c
  304.     , "int",jiange, "ptr",Scan0, "int",Stride
  305.     , "int",sx, "int",sy, "int",sw, "int",sh
  306.     , "ptr",&gs, "ptr",&ss
  307.     , "Astr",wz, "ptr",&s1, "ptr",&s0
  308.     , "ptr",&in, "int",num, "ptr",&out)
  309.   {
  310.     ocr:="", i:=-4  ; 返回第一个文字的中心位置
  311.     x:=NumGet(out,i+=4,"int"), y:=NumGet(out,i+=4,"int")
  312.     w:=NumGet(out,i+=4,"int"), h:=NumGet(out,i+=4,"int")
  313.     rx:=x+w//2, ry:=y+h//2
  314.     While (k:=NumGet(out,i+=4,"int"))
  315.       v:=wenzitab[k//7], ocr.=v="" ? "*" : v
  316.     Return, 1
  317.   }
  318.   Return, 0
  319. }

  320. MCode(ByRef code, hex)
  321. {
  322.   ListLines, Off
  323.   bch:=A_BatchLines
  324.   SetBatchLines, -1
  325.   VarSetCapacity(code, StrLen(hex)//2)
  326.   Loop, % StrLen(hex)//2
  327.     NumPut("0x" . SubStr(hex,2*A_Index-1,2)
  328.       , code, A_Index-1, "char")
  329.   Ptr:=A_PtrSize ? "Ptr" : "UInt"
  330.   DllCall("VirtualProtect", Ptr,&code, Ptr
  331.     ,VarSetCapacity(code), "uint",0x40, Ptr . "*",0)
  332.   SetBatchLines, %bch%
  333.   ListLines, On
  334. }

  335. base64tobit(s) {
  336.   ListLines, Off
  337.   s:=RegExReplace(s,"\s+")
  338.   Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  339.     . "abcdefghijklmnopqrstuvwxyz"
  340.   SetFormat, IntegerFast, d
  341.   StringCaseSense, On
  342.   Loop, Parse, Chars
  343.   {
  344.     i:=A_Index-1, v:=(i>>5&1) . (i>>4&1)
  345.       . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)
  346.     s:=StrReplace(s,A_LoopField,v)
  347.   }
  348.   StringCaseSense, Off
  349.   s:=SubStr(s,1,InStr(s,"1",0,0)-1)
  350.   ListLines, On
  351.   Return, s
  352. }

  353. bit2base64(s) {
  354.   ListLines, Off
  355.   s:=RegExReplace(s,"\s+")
  356.   s.=SubStr("100000",1,6-Mod(StrLen(s),6))
  357.   s:=RegExReplace(s,".{6}","|$0")
  358.   Chars:="0123456789+/ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  359.     . "abcdefghijklmnopqrstuvwxyz"
  360.   SetFormat, IntegerFast, d
  361.   Loop, Parse, Chars
  362.   {
  363.     i:=A_Index-1, v:="|" . (i>>5&1) . (i>>4&1)
  364.       . (i>>3&1) . (i>>2&1) . (i>>1&1) . (i&1)
  365.     s:=StrReplace(s,v,A_LoopField)
  366.   }
  367.   ListLines, On
  368.   Return, s
  369. }


  370. /************  机器码的C源码 ************

  371. int __attribute__((__stdcall__)) OCR( int mode
  372.   , unsigned int c, int jiange, unsigned char * Bmp
  373.   , int Stride, int sx, int sy, int sw, int sh
  374.   , unsigned char * gs, char * ss
  375.   , char * wz, int * s1, int * s0
  376.   , int * in, int num, int * out )
  377. {
  378.   int x, y, o=sy*Stride+sx*4, j=Stride-4*sw, i=0;
  379.   int o1, o2, w, h, max, len1, len0, e1, e0;
  380.   int sx1=0, sy1=0, sw1=sw, sh1=sh, Ptr=0;

  381.   //准备工作一:先将图像各点在ss中转化为01字符
  382.   if (mode==0)    //颜色模式
  383.   {
  384.     int R=(c>>16)&0xFF, G=(c>>8)&0xFF, B=c&0xFF;
  385.     for (y=0; y<sh; y++, o+=j)
  386.       for (x=0; x<sw; x++, o+=4, i++)
  387.         if (Bmp[2+o]==R && Bmp[1+o]==G && Bmp[o]==B)
  388.           ss[i]='1';
  389.   }
  390.   else if (mode==1)    //灰度阀值模式
  391.   {
  392.     c=(c+1)*128;
  393.     for (y=0; y<sh; y++, o+=j)
  394.       for (x=0; x<sw; x++, o+=4, i++)
  395.         if (Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15<c)
  396.           ss[i]='1';
  397.   }
  398.   else    //mode==2,边缘灰差模式
  399.   {
  400.     for (y=0; y<sh; y++, o+=j)
  401.     {
  402.       for (x=0; x<sw; x++, o+=4, i++)
  403.         gs[i]=(Bmp[2+o]*38+Bmp[1+o]*75+Bmp[o]*15)>>7;
  404.     }
  405.     w=sw-1; h=sh-1;
  406.     for (y=1; y<h; y++)
  407.     {
  408.       for (x=1; x<w; x++)
  409.       {
  410.         i=y*sw+x; j=gs[i]+c;
  411.         if (gs[i-1]>j || gs[i+1]>j
  412.           || gs[i-sw]>j || gs[i+sw]>j)
  413.             ss[i]='1';
  414.       }
  415.     }
  416.   }

  417.   //准备工作二:生成s1、s0查表数组
  418.   for (i=0; i<num; i+=7)
  419.   {
  420.     o=o1=o2=in[i]; w=in[i+1]; h=in[i+2];
  421.     for (y=0; y<h; y++)
  422.     {
  423.       for (x=0; x<w; x++)
  424.       {
  425.         if (wz[o++]=='1')
  426.           s1[o1++]=y*sw+x;
  427.         else
  428.           s0[o2++]=y*sw+x;
  429.       }
  430.     }
  431.   }

  432.   //正式工作:ss中每一点都进行一次全字库匹配
  433.   NextWenzi:
  434.   o=sy1*sw+sx1; o1=1-sw*sh1;
  435.   for (x=0; x<sw1; x++, o+=o1)
  436.   {
  437.     for (y=0; y<sh1; y++, o+=sw)
  438.     {
  439.       for (i=0; i<num; i+=7)
  440.       {
  441.         w=in[i+1]; h=in[i+2];
  442.         if (x+w>sw1 || y+h>sh1)
  443.           continue;
  444.         o2=in[i]; len1=in[i+3]; len0=in[i+4];
  445.         e1=in[i+5]; e0=in[i+6];
  446.         max=len1>len0 ? len1 : len0;
  447.         for (j=0; j<max; j++)
  448.         {
  449.           if (j<len1 && ss[o+s1[o2+j]]!='1' && (--e1)<0)
  450.             goto NoMatch;
  451.           if (j<len0 && ss[o+s0[o2+j]]!='0' && (--e0)<0)
  452.             goto NoMatch;
  453.         }
  454.         //成功找到文字或图像
  455.         if (Ptr==0)
  456.         {
  457.           out[0]=sx+x; out[1]=sy+y;
  458.           out[2]=w; out[3]=h; Ptr=4;
  459.           //找到第一个字就确定后续查找的上下范围和右边范围
  460.           sy1=y-h; sh1=h*3; sw1=h*10+100;
  461.           if (sy1<0)
  462.             sy1=0;
  463.           if (sh1>sh-sy1)
  464.             sh1=sh-sy1;
  465.         }
  466.         else if (x>jiange)  //与前一字间隔较远就添加*号
  467.           out[Ptr++]=-1;
  468.         out[Ptr++]=i+7;
  469.         if (Ptr>1021)    //返回的int数组中元素个数不超过1024
  470.           goto ReturnOK;
  471.         //继续从当前文字右边再次查找
  472.         sx1+=x+w;
  473.         if (sw1>sw-sx1)
  474.           sw1=sw-sx1;
  475.         goto NextWenzi;
  476.         //------------
  477.         NoMatch:
  478.         continue;
  479.       }
  480.     }
  481.   }
  482.   if (Ptr==0)
  483.     return 0;
  484.   ReturnOK:
  485.   out[Ptr]=0;
  486.   return 1;
  487. }

  488. */
  489. ;============ 脚本结束 =================;
复制代码

作者: tt911    时间: 2017-10-23 17:41
大家拿起手中的武器给坏蛋,尽情的扣分吧。
作者: 易广白    时间: 2017-10-23 18:52
看不懂,但支持酒大发干货
作者: wuyouaaa    时间: 2017-10-24 11:55
如果用userscript的话可以直接在页面内查找内容,免去ocr过程
作者: 天堂假日    时间: 2018-1-4 09:32
tt911大佬,麻烦重新分享下《单文件,袖珍实用记事本的替代品,显行行号,列选择,总在最前面,无限撤销操作 》这个附件,CT网盘下载不了。感谢大佬!!!




欢迎光临 无忧启动论坛 (http://wuyou.net./) Powered by Discuz! X3.3