安卓/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 pointsUTF8.InStr(1, str2, UTF8.Mid(str1, i, 1))1, pointsUTF8.InStr(1, str2, UTF8.Mid(str1, i, 1))2,200

Delay 1000

Next

Tap points101,points102

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会更加边界的帮助开发者解决游戏验证和答题

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

相关推荐
小羊没烦恼!1 天前
初探性能优化——2个月到4小时的性能提升
java·开发语言·windows·算法·c#
千里马学框架1 天前
一起学 Android 14:ShellTransition 屏幕旋转过程深度剖析
android·智能手机·性能优化·framework·性能·屏幕旋转·rotation
美狐美颜SDK开放平台1 天前
开发直播APP时如何接入视频美颜SDK?开发流程与注意事项
android·人工智能·计算机视觉·音视频·直播美颜sdk
AFinalStone1 天前
Android7 SystemUI源码解析(七)Keyguard锁屏模块深度解析
android·systemui
伞伞悦读1 天前
【第38期】Python 模块与包详解:import、from、模块搜索路径、包结构和 __init__
开发语言·python
致远ccc1 天前
Google Play 上架前如何测试 App?多国家 Android 环境测试
android·app测试·googleplay·多国家应用测试
C语言小火车1 天前
C/C++ 为什么需要编译器?
开发语言·c++
霍霍的袁1 天前
【C++】map 和 set 的使用 | 从用法到底层
开发语言·c++·学习·visual studio
ttyyttemo1 天前
Kotlin 协程中的 Job 结构化并发与取消
android
孙启超1 天前
【AI开发之Rust】第 11 课:智能指针与内部可变性
开发语言·后端·rust