• 按键公众号 :
按键精灵电脑版
立即下载

软件版本:2014.06
软件大小:22.9M
更新时间:2021-12-03

按键精灵安卓版
立即下载

软件版本:3.7.2
软件大小:46.2M
更新时间:2023-05-10

按键精灵iOS版
立即下载

软件版本:1.8.0
软件大小:29.2M
更新时间:2023-03-21

按键手机助手
立即下载

软件版本:3.8.0
软件大小:262M
更新时间:2023-05-30

快捷导航

登录 后使用快捷导航
没有帐号? 注册

发新话题 回复该主题

UMI识别文字方案的补全。得到文字坐标 [复制链接]

1#
本论坛的帖子 按键精灵调用Umi识别文字(本地无需做字库) _ 综合讨论 - 按键精灵论坛给出了本地建立服务器识别文字的方法。但我们要获取文字的同时还需要获取文字坐标,原帖子的方案就不行了。
原来想直接用按键精灵写个将图片在memory转码为base64的函数,但这个按键精灵的字节操作实在是乱,尝试了很久不行。后来用VB6直接做了个截屏转码的插件,解决了这个问题。
插件有2个函数
Plugin.SCTOBASE64.CaptureScreenRegionToBase64(x1, y1, x2, y2) 参数为目标区域相对屏幕的左上右下坐标,返回BASE64码
Plugin.SCTOBASE64.CaptureBackgroundWindowToBase64(hwd,x1, y1, x2, y2) 参数1为窗口句柄,记得是父窗口的句柄,这个在windows8以下不一定能返回正确图像,如果返回大量A,则找不到图像。

插件链接
通过网盘分享的文件:SCTOBASE64.zip
链接: https://pan.baidu.com/s/1CM7qL_On5LjbTe0EA40R6Q?pwd=qsqv 提取码: qsqv

以下的代码要下载论坛的免费神梦HTTP插件支持
  1. 返回文字
  2. Function 找字(x1, y1, x2, y2)
  3. Dim txt
  4. txt=""
  5. Dim URL,JsonData,json,username,password,base64
  6. URL = "http://127.0.0.1:1224/api/ocr"
  7. Base64 = Plugin.SCTOBASE64.CaptureScreenRegionToBase64(x1, y1, x2, y2)
  8. JsonData = SmHTTP.JsonData( _
  9. "base64",base64 , _
  10. "options", SmHTTP.JsonData( _
  11. "tbpu.parser","single_none",_
  12. "data.format","text"_
  13. ),_
  14. "Content-Type", "application/json" _
  15. )
  16. json = SmHTTP.HTTP_POST(URL, JsonData)
  17. If SmHTTP.GetStatus() = 200 Then
  18. If SmHTTP.GetJSON(json, "code") = 100 Then
  19. txt = SmHTTP.GetJSON(json, "data")
  20. If IsNull(txt) Then
  21. txt=""
  22. End If
  23. End If
  24. End If
  25. 找字=txt
  26. End Function

  27. Function 后台找字(hwd,x1, y1, x2, y2)
  28. Dim txt
  29. txt=""
  30. Dim URL,JsonData,json,username,password,base64
  31. URL = "http://127.0.0.1:1224/api/ocr"
  32. Base64 = Plugin.SCTOBASE64.CaptureBackgroundWindowToBase64(hwd,x1, y1, x2, y2)
  33. JsonData = SmHTTP.JsonData( _
  34. "base64",base64 , _
  35. "options", SmHTTP.JsonData( _
  36. "tbpu.parser","single_none",_
  37. "data.format","text"_
  38. ),_
  39. "Content-Type", "application/json" _
  40. )
  41. json = SmHTTP.HTTP_POST(URL, JsonData)
  42. If SmHTTP.GetStatus() = 200 Then
  43. If SmHTTP.GetJSON(json, "code") = 100 Then
  44. txt = SmHTTP.GetJSON(json, "data")
  45. If IsNull(txt) Then
  46. txt=""
  47. End If
  48. End If
  49. End If
  50. 后台找字=txt
  51. End Function

  52. //未找到 b(0,0)返回null,返回一个二维数组,第一维大小为5,b(0,0)文字内容,b(1,0)\b(2,0)\b(3,0)\b(4,0)文字相对的左上右下坐标。第二维为返回字符串数量
  53. Function 区域找字坐标(x1,y1,x2,y2)
  54. Redim findt(4, 0)
  55. findt(0, 0)=null
  56. Dim URL,JsonData,json,username,password,base64,counts
  57. URL = "http://127.0.0.1:1224/api/ocr"
  58. Base64 = Plugin.SCTOBASE64.CaptureScreenRegionToBase64(x1, y1, x2, y2)
  59. JsonData = SmHTTP.JsonData( _
  60. "base64",base64 , _
  61. "Content-Type", "application/json" _
  62. )
  63. json = SmHTTP.HTTP_POST(URL, JsonData)
  64. counts=字符串数量(json)
  65. TracePrint counts & json
  66. If SmHTTP.GetStatus() = 200 Then
  67. If SmHTTP.GetJSON(json, "code") = 100 Then
  68. Dim xx,i
  69. xx = null
  70. i=0
  71. xx =SmHTTP.GetJSON(json, "data[0]['text']")
  72. Do Until i>counts-1
  73. xx=null
  74. xx = SmHTTP.GetJSON(json, "data[" & i & "]['text']")
  75. If not IsNull(xx) and not IsEmpty(SmHTTP.GetJSON(json, "data["& i &"]['box'][0][0]")) and not IsNull(SmHTTP.GetJSON(json, "data["& i &"]['box'][0][0]")) Then
  76. If i > 0 Then
  77. Redim Preserve findt(4, i)
  78. End If
  79. findt(0,i) = SmHTTP.GetJSON(json, "data[" & i & "]['text']")
  80. findt(1,i)=SmHTTP.GetJSON(json, "data["& i &"]['box'][0][0]")
  81. findt(2,i)=SmHTTP.GetJSON(json, "data["& i &"]['box'][0][1]")
  82. findt(3,i)=SmHTTP.GetJSON(json, "data["& i &"]['box'][2][0]")
  83. findt(4, i) = SmHTTP.GetJSON(json, "data[" & i & "]['box'][2][1]")
  84. End If
  85. i=i+1
  86. loop
  87. Else
  88. findt(1, 0)=-1
  89. End If
  90. Else
  91. findt(1, 0)=-2
  92. End If
  93. 区域找字坐标=findt
  94. End Function
复制代码
插件的VB6代码
  1. '--------------------------------------------------------------------------
  2. ' 您可以在这里添加自己的插件函数,插件的制作和使用方法如下:
  3. ' 第一步:在下面添加插件函数,一个插件可以添加多个函数。
  4. ' 第二步:请修改下面的Get_Plugin_Description函数,加入插件和插件函数的说明信息,帮助信息会显示在按键精灵里方便使用
  5. ' 第三步:请修改Class Module(类模块)的名字,尽量用一些独特的名字避免和别人的插件名字冲突(默认是MyPluginName)
  6. ' 第四步:生成插件DLL!将DLL文件放到按键精灵的PLUGIN目录下,然后启动按键精灵测试您制作的插件功能是否正常
  7. ' 对插件有任何问题请发邮件给我们: [email]hi@vrbrothers.com[/email]
  8. '--------------------------------------------------------------------------

  9. Option Explicit

  10. ' API声明
  11. Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
  12. Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long) As Long
  13. Private Declare Function CreateCompatibleBitmap Lib "gdi32" (ByVal hdc As Long, ByVal nWidth As Long, ByVal nHeight As Long) As Long
  14. Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal hObject As Long) As Long
  15. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
  16. Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
  17. Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
  18. Private Declare Function GetObject Lib "gdi32" Alias "GetObjectA" (ByVal hObject As Long, ByVal nCount As Long, lpObject As Any) As Long
  19. Private Declare Function GetDIBits Lib "gdi32" (ByVal aHDC As Long, ByVal hBitmap As Long, ByVal nStartScan As Long, ByVal nNumScans As Long, lpBits As Any, lpBI As Any, ByVal wUsage As Long) As Long
  20. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Destination As Any, Source As Any, ByVal length As Long)
  21. Private Declare Function CryptBinaryToString Lib "crypt32.dll" Alias "CryptBinaryToStringA" (ByVal pbBinary As Long, ByVal cbBinary As Long, ByVal dwFlags As Long, ByVal pszString As String, ByRef pcchString As Long) As Long

  22. Private Declare Function SetForegroundWindow Lib "user32" (ByVal hwnd As Long) As Long


  23. ' API声明
  24. Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
  25. Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As rect) As Long
  26. Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As rect) As Long
  27. Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hdc As Long) As Long
  28. Private Declare Function PrintWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal hdcBlt As Long, ByVal nFlags As Long) As Long

  29. '''''


  30. ' 结构体和常量
  31. Private Type rect
  32. Left As Long
  33. Top As Long
  34. Right As Long
  35. Bottom As Long
  36. End Type


  37. ' 常量定义
  38. Private Const CRYPT_STRING_BASE64 As Long = 1
  39. Private Const BI_RGB As Long = 0
  40. Private Const DIB_RGB_COLORS As Long = 0
  41. Private Const PW_RENDERFULLCONTENT As Long = 2 ' Windows 8+ 支持捕获完整内容


  42. ' 结构体定义
  43. Private Type BITMAP
  44. bmType As Long
  45. bmWidth As Long
  46. bmHeight As Long
  47. bmWidthBytes As Long
  48. bmPlanes As Integer
  49. bmBitsPixel As Integer
  50. bmBits As Long
  51. End Type

  52. Private Type BITMAPINFOHEADER
  53. biSize As Long
  54. biWidth As Long
  55. biHeight As Long
  56. biPlanes As Integer
  57. biBitCount As Integer
  58. biCompression As Long
  59. biSizeImage As Long
  60. biXPelsPerMeter As Long
  61. biYPelsPerMeter As Long
  62. biClrUsed As Long
  63. biClrImportant As Long
  64. End Type

  65. Private Type BITMAPFILEHEADER
  66. bfType As Integer
  67. bfSize As Long
  68. bfReserved1 As Integer
  69. bfReserved2 As Integer
  70. bfOffBits As Long
  71. End Type




  72. ' 截取后台窗口区域并转化为base64
  73. Public Function CaptureBackgroundWindowToBase64(hWndx As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal x2 As Long, ByVal y2 As Long) As String
  74. Dim hwnd As Long, hdcWindow As Long, hdcMem As Long, hBitmap As Long, hOldBmp As Long
  75. Dim hdcMem2 As Long, hBitmap2 As Long, hOldBmp2 As Long
  76. Dim rect As rect, clientRect As rect, bmpInfo As BITMAPINFOHEADER, bmpFileHeader As BITMAPFILEHEADER
  77. Dim pixelBytes() As Byte, bytes() As Byte
  78. Dim bufferSize As Long, retVal As Long
  79. Dim tempStr As String

  80. Dim Width As Long: Width = x2 - x1 ' 截取宽度
  81. Dim Height As Long: Height = y2 - y1 ' 截取高度
  82. Dim srcX As Long: srcX = x1 ' 截取起始X坐标(相对窗口左上角)
  83. Dim srcY As Long: srcY = y1 ' 截取起始Y坐标(相对窗口左上角)
  84. ' 通过窗口标题获取句柄
  85. hwnd = hWndx
  86. If hwnd = 0 Then
  87. Exit Function
  88. End If

  89. ' 获取窗口位置(仅用于区域定位,实际截图用PrintWindow)
  90. GetWindowRect hwnd, rect
  91. GetClientRect hwnd, clientRect

  92. Debug.Print rect.Left & " " & rect.Top & " " & rect.Right&; " " & rect.Bottom
  93. Debug.Print clientRect.Left & " " & clientRect.Top & " " & clientRect.Right&; " " & clientRect.Bottom
  94. Dim winWidth As Long: winWidth = rect.Right - rect.Left
  95. Dim winHeight As Long: winHeight = rect.Bottom - rect.Top
  96. Dim offX As Long: offX = clientRect.Left - rect.Left '客户区相对于母窗口的偏移
  97. Dim offY As Long: offY = clientRect.Top - rect.Top
  98. ' 检查截取区域是否在窗口范围内
  99. If srcX + Width + offX > winWidth Or srcY + Height + offY > winHeight Then
  100. Exit Function
  101. End If

  102. ' 创建兼容DC和位图
  103. hdcWindow = GetDC(hwnd)
  104. hdcMem = CreateCompatibleDC(hdcWindow)
  105. hBitmap = CreateCompatibleBitmap(hdcWindow, winWidth, winHeight) ' 截取目标区域
  106. hOldBmp = SelectObject(hdcMem, hBitmap)
  107. Debug.Print hwnd
  108. ' 使用PrintWindow捕获后台窗口(PW_RENDERFULLCONTENT需Windows 8+),win8以下这里设为0,但不一定能正常获取图像
  109. If PrintWindow(hwnd, hdcMem, PW_RENDERFULLCONTENT) = 0 Then
  110. GoTo Cleanup
  111. End If

  112. ' 创建第二个memoryDC和位图(用于截取目标区域)
  113. hdcMem2 = CreateCompatibleDC(hdcWindow)
  114. hBitmap2 = CreateCompatibleBitmap(hdcWindow, Width, Height)
  115. hOldBmp2 = SelectObject(hdcMem2, hBitmap2)

  116. ' 从原memoryDC的(srcX, srcY)位置复制目标区域到新位图
  117. If BitBlt(hdcMem2, 0, 0, Width, Height, hdcMem, srcX + offX, srcY + offY, vbSrcCopy) = 0 Then
  118. GoTo Cleanup
  119. End If


  120. ' 获取位图信息
  121. With bmpInfo
  122. .biSize = Len(bmpInfo)
  123. .biWidth = Width
  124. .biHeight = -Height ' 顶部到底部
  125. .biPlanes = 1
  126. .biBitCount = 24 ' 24位色
  127. .biCompression = BI_RGB
  128. .biSizeImage = ((Width * 3 + 3) \ 4) * 4 * Height ' 计算图像大小
  129. End With

  130. ' 获取像素数据
  131. ReDim pixelBytes(0 To bmpInfo.biSizeImage - 1)
  132. If GetDIBits(hdcMem2, hBitmap2, 0, Height, pixelBytes(0), bmpInfo, DIB_RGB_COLORS) = 0 Then
  133. ' MsgBox "获取像素数据失败!", vbExclamation
  134. GoTo Cleanup
  135. End If

  136. ' 构造BMP文件头
  137. With bmpFileHeader
  138. .bfType = &H4D42 ' "BM"
  139. .bfSize = Len(bmpFileHeader) + Len(bmpInfo) + bmpInfo.biSizeImage
  140. .bfOffBits = Len(bmpFileHeader) + Len(bmpInfo)
  141. End With

  142. ' 合并为完整BMP数据
  143. ReDim bytes(0 To bmpFileHeader.bfSize - 1)
  144. ' 1. bfType (2字节)
  145. bytes(0) = &H42 ' "B"
  146. bytes(1) = &H4D ' "M"
  147. ' 2. bfSize (4字节,小端序)
  148. CopyMemory bytes(2), bmpFileHeader.bfSize, 4
  149. ' 3. bfReserved1/2 (4字节)
  150. bytes(6) = 0: bytes(7) = 0: bytes(8) = 0: bytes(9) = 0
  151. ' 4. bfOffBits (4字节,小端序)
  152. CopyMemory bytes(10), bmpFileHeader.bfOffBits, 4

  153. CopyMemory bytes(Len(bmpFileHeader)), bmpInfo, Len(bmpInfo)
  154. CopyMemory bytes(Len(bmpFileHeader) + Len(bmpInfo)), pixelBytes(0), bmpInfo.biSizeImage

  155. ' 保存为BMP文件,此段注释掉,为检查代码能否正常运行设置

  156. 'Dim FileNum As Integer
  157. 'Dim FilePath As String
  158. ' FilePath = "d:\test2.bmp"
  159. ' FileNum = FreeFile()
  160. ' Open FilePath For Binary Access Write As #FileNum
  161. ' Put #FileNum, 1, bytes()
  162. ' Close #FileNum



  163. ' 转换为Base64
  164. bufferSize = 0
  165. CryptBinaryToString VarPtr(bytes(0)), UBound(bytes) + 1, CRYPT_STRING_BASE64, vbNullString, bufferSize
  166. tempStr = Space$(bufferSize)
  167. retVal = CryptBinaryToString(VarPtr(bytes(0)), UBound(bytes) + 1, CRYPT_STRING_BASE64, tempStr, bufferSize)
  168. If retVal Then
  169. tempStr = Left$(tempStr, bufferSize - 1)
  170. tempStr = Replace$(tempStr, vbCrLf, "") ' 先处理Windows换行符
  171. tempStr = Replace$(tempStr, vbCr, "") ' 再处理Mac旧换行符
  172. tempStr = Replace$(tempStr, vbLf, "") ' 最后处理Unix换行符
  173. CaptureBackgroundWindowToBase64 = Left$(tempStr, bufferSize - 1)
  174. End If


  175. Cleanup:
  176. ' 清理资源
  177. If hdcMem2 <> 0 Then
  178. SelectObject hdcMem2, hOldBmp2
  179. DeleteObject hBitmap2
  180. DeleteDC hdcMem2
  181. End If
  182. If hdcMem <> 0 Then
  183. SelectObject hdcMem, hOldBmp
  184. DeleteObject hBitmap
  185. DeleteDC hdcMem
  186. End If
  187. If hdcWindow <> 0 Then ReleaseDC hwnd, hdcWindow
  188. End Function

  189. ' 截取屏幕区域并返回Base64编码
  190. Public Function CaptureScreenRegionToBase64(ByVal x As Long, ByVal y As Long, ByVal x1 As Long, ByVal y1 As Long) As String
  191. Dim hScreenDC As Long, hMemDC As Long, hBitmap As Long, hOldBitmap As Long
  192. Dim bmp As BITMAP, bmpInfo As BITMAPINFOHEADER, bmpFileHeader As BITMAPFILEHEADER
  193. Dim pixelBytes() As Byte, bytes() As Byte
  194. Dim result As Long, bufferSize As Long, retVal As Long
  195. Dim tempStr As String
  196. Dim Width As Long, Height As Long
  197. Width = x1 - x
  198. Height = y1 - y
  199. ' 获取屏幕设备上下文
  200. hScreenDC = GetDC(0)
  201. If hScreenDC = 0 Then Exit Function

  202. ' 创建兼容DC和位图
  203. hMemDC = CreateCompatibleDC(hScreenDC)
  204. If hMemDC = 0 Then GoTo Cleanup
  205. hBitmap = CreateCompatibleBitmap(hScreenDC, Width, Height)
  206. If hBitmap = 0 Then GoTo Cleanup
  207. hOldBitmap = SelectObject(hMemDC, hBitmap)

  208. ' 复制屏幕区域
  209. result = BitBlt(hMemDC, 0, 0, Width, Height, hScreenDC, x, y, vbSrcCopy)
  210. If result = 0 Then GoTo Cleanup

  211. ' 获取位图信息
  212. GetObject hBitmap, Len(bmp), bmp


  213. ' 设置BITMAPINFOHEADER
  214. With bmpInfo
  215. .biSize = Len(bmpInfo)
  216. .biWidth = bmp.bmWidth
  217. .biHeight = -bmp.bmHeight ' 顶部到底部
  218. .biPlanes = 1
  219. .biBitCount = 24 ' 24位色
  220. .biCompression = BI_RGB
  221. .biSizeImage = ((bmp.bmWidth * 3 + 3) \ 4) * 4 * bmp.bmHeight ' 计算图像大小
  222. End With

  223. ' 获取像素数据
  224. ReDim pixelBytes(0 To bmpInfo.biSizeImage - 1)
  225. result = GetDIBits(hMemDC, hBitmap, 0, bmp.bmHeight, pixelBytes(0), bmpInfo, DIB_RGB_COLORS)
  226. If result = 0 Then GoTo Cleanup

  227. ' 构造BMP文件头
  228. With bmpFileHeader
  229. .bfType = &H4D42 ' "BM"
  230. .bfSize = Len(bmpFileHeader) + Len(bmpInfo) + bmpInfo.biSizeImage
  231. .bfOffBits = Len(bmpFileHeader) + Len(bmpInfo)
  232. End With

  233. ' 手动写入文件头(确保正确的字节顺序)
  234. ReDim bytes(0 To bmpFileHeader.bfSize - 1)
  235. ' 1. bfType (2字节)
  236. bytes(0) = &H42 ' "B"
  237. bytes(1) = &H4D ' "M"
  238. ' 2. bfSize (4字节,小端序)
  239. CopyMemory bytes(2), bmpFileHeader.bfSize, 4
  240. ' 3. bfReserved1/2 (4字节)
  241. bytes(6) = 0: bytes(7) = 0: bytes(8) = 0: bytes(9) = 0
  242. ' 4. bfOffBits (4字节,小端序)
  243. CopyMemory bytes(10), bmpFileHeader.bfOffBits, 4

  244. CopyMemory bytes(Len(bmpFileHeader)), bmpInfo, Len(bmpInfo)
  245. CopyMemory bytes(Len(bmpFileHeader) + Len(bmpInfo)), pixelBytes(0), bmpInfo.biSizeImage

  246. ' 保存为BMP文件,测试程序时使用,备注掉

  247. ' Dim FileNum As Integer
  248. ' Dim FilePath As String
  249. ' FilePath = "d:\test1.bmp"
  250. ' FileNum = FreeFile()
  251. ' Open FilePath For Binary Access Write As #FileNum
  252. ' Put #FileNum, 1, bytes()
  253. ' Close #FileNum



  254. ' 转换为Base64
  255. bufferSize = 0
  256. CryptBinaryToString VarPtr(bytes(0)), UBound(bytes) + 1, CRYPT_STRING_BASE64, vbNullString, bufferSize
  257. tempStr = Space$(bufferSize)
  258. retVal = CryptBinaryToString(VarPtr(bytes(0)), UBound(bytes) + 1, CRYPT_STRING_BASE64, tempStr, bufferSize)



  259. If retVal Then
  260. tempStr = Left$(tempStr, bufferSize - 1)
  261. tempStr = Replace$(tempStr, vbCrLf, "") ' 先处理Windows换行符
  262. tempStr = Replace$(tempStr, vbCr, "") ' 再处理Mac旧换行符
  263. tempStr = Replace$(tempStr, vbLf, "") ' 最后处理Unix换行符
  264. CaptureScreenRegionToBase64 = tempStr
  265. End If
  266. Cleanup:
  267. ' 清理资源
  268. If hMemDC <> 0 Then
  269. SelectObject hMemDC, hOldBitmap
  270. DeleteObject hBitmap
  271. DeleteDC hMemDC
  272. End If
  273. DeleteDC hScreenDC
  274. End Function

  275. '下面这个函数为您的插件提供帮助信息,请只修改和添加里面的描述信息,而不要修改函数本身
  276. Public Function Get_Plugin_Description(ItemName As String) As String
  277. Dim Description_Text As String
  278. Description_Text = ""
  279. Select Case ItemName
  280. Case ""
  281. Description_Text = "在这里写您的插件的说明信息"
  282. Case "CaptureBackgroundWindowToBase64"
  283. Description_Text = "CaptureBackgroundWindowToBase64,截取后台窗口区域图像并转为base64"
  284. Case "CaptureScreenRegionToBase64"
  285. Description_Text = "CaptureScreenRegionToBase64,截取屏幕区域图像并转为base64"

  286. '------------------------------------------------
  287. '为您的每个插件函数建立一个Case,就可以在按键精灵里显示插件的使用说明
  288. '------------------------------------------------
  289. End Select
  290. Get_Plugin_Description = Translate_Description(Description_Text)
  291. End Function

  292. '下面这个函数为您的插件提供显示模板信息,请只修改和添加里面的描述信息,而不要修改函数本身
  293. '描述信息中的$1 $2 ... 等内容再显示时将用第一个参数、第二个参数、... 代替
  294. Public Function Get_Plugin_Interpret_Template(ItemName As String) As String
  295. Dim Description_Text As String
  296. Description_Text = ""
  297. Select Case ItemName
  298. Case ""
  299. Description_Text = "在这里写您的插件的说明信息"
  300. Case "CaptureBackgroundWindowToBase64"
  301. Description_Text = "参数1为窗口句柄,参数2、3为截取图片左上角相对于后台窗口左上角的X/Y坐标,参数4、5为右下角坐标"
  302. Case "CaptureScreenRegionToBase64"
  303. Description_Text = "参数1、2为截取图片左上角的X/Y坐标,参数3、4为右下角坐标"

  304. '------------------------------------------------
  305. '为您的每个插件函数建立一个Case,就可以在按键精灵里显示插件的使用说明
  306. '------------------------------------------------
  307. End Select
  308. Get_Plugin_Interpret_Template = Translate_Description(Description_Text)
  309. End Function
复制代码

2#

umiocr返回的包含对应文字的坐标

假设umiocr返回的json为
{"data": [

{"box": [[1282, 1104], [1501, 1104], [1501, 1148], [1282, 1148]], "score": 0.9156272411346436, "text": "\u6276\u98ce\u53bf\u516c\u5b89\u5c40", "end": "\n"},

{"box": [[1282, 1185], [1563, 1185], [1563, 1222], [1282, 1222]],"score": 0.8834136128425598, "text": "20QP0531\u957f\u671f", "end": "\n"}

]
};

方括号里就是text对应的坐标
在浏览器里运行一下命令,就可以输出坐标(两个弹窗)
var json1={"data": [

{"box": [[1282, 1104], [1501, 1104], [1501, 1148], [1282, 1148]], "score": 0.9156272411346436, "text": "\u6276\u98ce\u53bf\u516c\u5b89\u5c40", "end": "\n"},

{"box": [[1282, 1185], [1563, 1185], [1563, 1222], [1282, 1222]],"score": 0.8834136128425598, "text": "20QP0531\u957f\u671f", "end": "\n"}

]
};
for(var i=0;i<json1.data.length;i++){alert(json1.data.box)}

此网页显示 1282.1104.1501.1104.1501.1148.1282.1148
此网页显示 1282,1185,1563,1185,1563,1222,1282,1222

发新话题 回复该主题