安卓/IOS工具开发基础教程:按键精灵一个简单的文字识别游戏验证

怎么用用脚本识别这个游戏验证,效果图:

这个验证需要识别两部分,一是顶部的验证文字,二是每个按钮上面的文字。

对于大量文字的中文识别按键本身没啥太好的识别方式,所以要依靠第三方,我选择用百度云识别。

脚本的思路有五步:

①获取每个按钮的坐标存入数组

②分别识别两部分的文字,第一部分是4个字,第二部分是9个字

③逐个遍历4个字在9个字中的位置,如我们例子中:

悄(3)锦(2)邦(6)番(9)

④把这些位置的数字当做第一步中按钮坐标的数组下标,就可以知道这4个字的位置了。

⑤按照坐标逐个按钮点击。

具体代码如下:

Import "shanhai.lua"

Dim token="填写你自己的百度token"

Dim points={{169,434},{276,439},{386,438},{158,538},{261,542},{391,530},{184,616},{285,617},{381,617},{327,706}}

Dim path="/sdcard/pictures/abc.png"

snapshot(path,241,270,336,313)

dim str1= baiduocr(token, path)

snapshot(path,119,409,430,671)

dim str2= baiduocr(token, path)

TracePrint str1,str2

For i = 1 To utf8.Len(str1)

TracePrint utf8.InStr(1,str2,utf8.mid(str1,i,1))

touch points[UTF8.InStr(1, str2, UTF8.Mid(str1, i, 1))][1], points[UTF8.InStr(1, str2, UTF8.Mid(str1, i, 1))][2],200

Delay 1000

Next

Tap points[10][1],points[10][2]

Function baiduocr(token, path)

Import "shanhai.lua"

Dim base64=ShanHai.ReadFileBase(path)

Dim 图片=shanhai.CharToUrl(base64)

Dim post内容="access_token="&token&"&Content-Type=application/x-www-form-urlencoded&image="&图片&"&detect_direction=true"

Dim myjson=url.post("https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic",post内容)

Dim table=encode.JsonToTable(myjson)

Dim ret_arr()

For i = 0 To UBOUND(table["words_result"])

ret_arr(i)=table["words_result"][i+1]["words"]

Next

baiduocr=join(ret_arr,"")

End Function

这个是基础的教程,新开发的ocrex会更加边界的帮助开发者解决游戏验证和答题

这边也感谢按键作者郭老师的经验分享

相关推荐
tobebetter95274 小时前
How to manage python versions on windows
开发语言·windows·python
9***P3345 小时前
PHP代码覆盖率
开发语言·php·代码覆盖率
CoderYanger5 小时前
优选算法-栈:67.基本计算器Ⅱ
java·开发语言·算法·leetcode·职场和发展·1024程序员节
jllllyuz6 小时前
Matlab实现基于Matrix Pencil算法实现声源信号角度和时间估计
开发语言·算法·matlab
多多*6 小时前
Java复习 操作系统原理 计算机网络相关 2025年11月23日
java·开发语言·网络·算法·spring·microsoft·maven
p***43486 小时前
Rust网络编程模型
开发语言·网络·rust
ᐇ9596 小时前
Java集合框架深度实战:构建智能教育管理与娱乐系统
java·开发语言·娱乐
梁正雄7 小时前
1、python基础语法
开发语言·python
zhaoyufei1337 小时前
Android13删除Taskbar
android
强化学习与机器人控制仿真7 小时前
RSL-RL:开源人形机器人强化学习控制研究库
开发语言·人工智能·stm32·神经网络·机器人·强化学习·模仿学习