全屏下选择屏幕文字并识别脚本

requestScreenCapture();
var window = floaty.window(
<frame >
<vertical>
<img w="200" h="200" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAABGdBTUEAALGPC/xhBQAACk1pQ0NQUGhvdG9zaG9wIElDQyBwcm9maWxlAAB4nJ1Td1iT9xY+3/dlD1ZC2PCxl2yBACIjrAjIEFmiEJIAYYQQEkDFhYgKVhQVEZxIVcSC1QpInYjioCi4Z0GKiFqLVVw47h/cp7V9eu/t7fvX+7znnOf8znnPD4AREiaR5qJqADlShTw62B+PT0jEyb2AAhVI4AQgEObLwmcFxQAA8AN5eH50sD/8Aa9vAAIAcNUuJBLH4f+DulAmVwAgkQDgIhLnCwGQUgDILlTIFADIGACwU7NkCgCUAABseXxCIgCqDQDs9Ek+BQDYqZPcFwDYohypCACNAQCZKEckAkC7AGBVgVIsAsDCAKCsQCIuBMCuAYBZtjJHAoC9BQB2jliQD0BgAICZQizMACA4AgBDHhPNAyBMA6Aw0r/gqV9whbhIAQDAy5XNl0vSMxS4ldAad/Lw4OIh4sJssUJhFykQZgnkIpyXmyMTSOcDTM4MAAAa+dHB/jg/kOfm5OHmZuds7/TFov5r8G8iPiHx3/68jAIEABBOz+/aX+Xl1gNwxwGwdb9rqVsA2lYAaN/5XTPbCaBaCtB6+Yt5OPxAHp6hUMg8HRwKCwvtJWKhvTDjiz7/M+Fv4It+9vxAHv7bevAAcZpAma3Ao4P9cWFudq5SjufLBEIxbvfnI/7HhX/9jinR4jSxXCwVivFYibhQIk3HeblSkUQhyZXiEul/MvEflv0Jk3cNAKyGT8BOtge1y2zAfu4BAosOWNJ2AEB+8y2MGguRABBnNDJ59wAAk7/5j0ArAQDNl6TjAAC86BhcqJQXTMYIAABEoIEqsEEHDMEUrMAOnMEdvMAXAmEGREAMJMA8EEIG5IAcCqEYlkEZVMA62AS1sAMaoBGa4RC0wTE4DefgElyB63AXBmAYnsIYvIYJBEHICBNhITqIEWKO2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BB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIeIewN2kC1cMcAAAAASUVORK5CYII="/>
</vertical>
<vertical>
<text id="action" text="双击拖动选择" color="#000000" gravity="bottom" w="200" h="200" bg="#00000000"/>
</vertical>
</frame>
);
ti=0;
tim=[];
var execution = null;
var x = 0, y = 0;
var windowX, windowY;
var downTime;
window.action.setOnTouchListener(function(view, event){
switch(event.getAction()){
case event.ACTION_DOWN:
x = event.getRawX();
y = event.getRawY();
windowX = window.getX();//+335
windowY = window.getY();//+335或+390
tim[ti] = new Date().getTime();
ti++;
return true;
case event.ACTION_MOVE:
if(ti>1&&tim[ti-1]-tim[ti-2]<200){window.action.setText('选择中');}else{}
window.setPosition(windowX + (event.getRawX() - x),
windowY + (event.getRawY() - y));
return true;
case event.ACTION_UP:
if(ti>1&&tim[ti-1]-tim[ti-2]<200){
window.action.setText('正在识别中');
threads.start(function(){
var str=gettext(windowX+335,windowY+335,window.getX()+335,window.getY()+335);
setClip(str);
ui.run(function(){window.action.setText(str);});
});
}else{}
//window.action.setText('双击拖动选择');
return true;
}
return true;
});

function gettext(x1,y1,x2,y2){
if(x1>x2){
var tmp=x1;
x1=x2;x2=tmp;
}
if(y1>y2){
var tmp=y1;
y1=y2;y2=tmp;
}
path="/storage/emulated/0/DCIM/Screenshots/";
img1_path=path+"Screenshot.png";
images.saveImage(capturescreen(),img1_path);
img2_path=path+"S.png";
clippng(img1_path,x1,y1,x2-x1,y2-y1,img2_path);
str=getimgtext(img2_path);
//setClip(str);
//{"result":[{"content":"ll令0E\n","frame":["37,6","199,6","199,41","37,41"]},{"content":"0imag\n","frame":["42,242","199,242","199,273","42,273"]},{"content":"img2\n","frame":["112,287","197,287","197,327","112,327"]},{"content":"2clir\n","frame":["42,336","197,336","197,369","42,369"]}],"success":1}
str=cutstr(str,'{"content":"','","frame":');
//eval("str="+str);
str =str.split("\n");
str=str.join(" ");
return str;
}//获取两个点之间文字,左上角和右下角
function cutstr(a, b, c) {
a = a.split(b);var d="";
for (i = 1; i < a.length; i++) {
var tmp = a[i].split(c);
if (tmp.length > 1) {
d+=tmp[0];
}
}return d;
}//截取指定头围中的字符串
function getimgtext(path){
var url="http://pic.sogou.com/pic/upload_pic.jsp";
var res=http.postMultipart(url,{
"file": open(path),
});
var t=res.body.string();
res=http.get("http://pic.sogou.com/pic/ocr/ocrOnline.jsp?query="+t);
t=res.body.string();
return t;
}//通过搜狗ocr获取路径图片里的文字
function clippng(path1,x,y,w,h,path2){
var p=android.graphics.BitmapFactory.decodeFile(path1);//从内存卡读取图片
var p2=android.graphics.Bitmap.createBitmap(p,x,y,w,h);
saveBitmap(p2,path2);
}//裁剪.png图片
function saveBitmap(mBitmap,bitName){
var f = new java.io.File(bitName);
var fOut = null;
fOut = new java.io.FileOutputStream(f);
mBitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fOut);
}//保存bitmap图片
function capturescreen() {
while (true) {
if (ajt = captureScreen()) {
return ajt;
break;
}
}
} //截图

while(true){sleep(1000);}

@bw6a4sp1kwn全屏下选择屏幕文字并识别脚本 中说:

requestScreenCapture();
var window = floaty.window(
<frame >
<vertical>
<img w="200" h="200" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfQAAAH0CAYAAADL1t+KAAAABGdBTUEAALGPC/xhBQAACk1pQ0NQUGhvdG9zaG9wIElDQyBwcm9maWxlAAB4nJ1Td1iT9xY+3/dlD1ZC2PCxl2yBACIjrAjIEFmiEJIAYYQQEkDFhYgKVhQVEZxIVcSC1QpInYjioCi4Z0GKiFqLVVw47h/cp7V9eu/t7fvX+7znnOf8znnPD4AREiaR5qJqADlShTw62B+PT0jEyb2AAhVI4AQgEObLwmcFxQAA8AN5eH50sD/8Aa9vAAIAcNUuJBLH4f+DulAmVwAgkQDgIhLnCwGQUgDILlTIFADIGACwU7NkCgCUAABseXxCIgCqDQDs9Ek+BQDYqZPcFwDYohypCACNAQCZKEckAkC7AGBVgVIsAsDCAKCsQCIuBMCuAY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HQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIEHQACBB0AAgQdAAIeIewN2kC1cMcAAAAASUVORK5CYII="/>
</vertical>
<vertical>
<text id="action" text="双击拖动选择" color="#000000" gravity="bottom" w="200" h="200" bg="#00000000"/>
</vertical>
</frame>
);
ti=0;
tim=[];
var execution = null;
var x = 0, y = 0;
var windowX, windowY;
var downTime;
window.action.setOnTouchListener(function(view, event){
switch(event.getAction()){
case event.ACTION_DOWN:
x = event.getRawX();
y = event.getRawY();
windowX = window.getX();//+335
windowY = window.getY();//+335或+390
tim[ti] = new Date().getTime();
ti++;
return true;
case event.ACTION_MOVE:
if(ti>1&&tim[ti-1]-tim[ti-2]<200){window.action.setText('选择中');}else{}
window.setPosition(windowX + (event.getRawX() - x),
windowY + (event.getRawY() - y));
return true;
case event.ACTION_UP:
if(ti>1&&tim[ti-1]-tim[ti-2]<200){
window.action.setText('正在识别中');
threads.start(function(){
var str=gettext(windowX+335,windowY+335,window.getX()+335,window.getY()+335);
setClip(str);
ui.run(function(){window.action.setText(str);});
});
}else{}
//window.action.setText('双击拖动选择');
return true;
}
return true;
});

function gettext(x1,y1,x2,y2){
if(x1>x2){
var tmp=x1;
x1=x2;x2=tmp;
}
if(y1>y2){
var tmp=y1;
y1=y2;y2=tmp;
}
path="/storage/emulated/0/DCIM/Screenshots/";
img1_path=path+"Screenshot.png";
images.saveImage(capturescreen(),img1_path);
img2_path=path+"S.png";
clippng(img1_path,x1,y1,x2-x1,y2-y1,img2_path);
str=getimgtext(img2_path);
//setClip(str);
//{"result":[{"content":"ll令0E\n","frame":["37,6","199,6","199,41","37,41"]},{"content":"0imag\n","frame":["42,242","199,242","199,273","42,273"]},{"content":"img2\n","frame":["112,287","197,287","197,327","112,327"]},{"content":"2clir\n","frame":["42,336","197,336","197,369","42,369"]}],"success":1}
str=cutstr(str,'{"content":"','","frame":');
//eval("str="+str);
str =str.split("\n");
str=str.join(" ");
return str;
}//获取两个点之间文字,左上角和右下角
function cutstr(a, b, c) {
a = a.split(b);var d="";
for (i = 1; i < a.length; i++) {
var tmp = a[i].split(c);
if (tmp.length > 1) {
d+=tmp[0];
}
}return d;
}//截取指定头围中的字符串
function getimgtext(path){
var url="http://pic.sogou.com/pic/upload_pic.jsp";
var res=http.postMultipart(url,{
"file": open(path),
});
var t=res.body.string();
res=http.get("http://pic.sogou.com/pic/ocr/ocrOnline.jsp?query="+t);
t=res.body.string();
return t;
}//通过搜狗ocr获取路径图片里的文字
function clippng(path1,x,y,w,h,path2){
var p=android.graphics.BitmapFactory.decodeFile(path1);//从内存卡读取图片
var p2=android.graphics.Bitmap.createBitmap(p,x,y,w,h);
saveBitmap(p2,path2);
}//裁剪.png图片
function saveBitmap(mBitmap,bitName){
var f = new java.io.File(bitName);
var fOut = null;
fOut = new java.io.FileOutputStream(f);
mBitmap.compress(android.graphics.Bitmap.CompressFormat.PNG, 100, fOut);
}//保存bitmap图片
function capturescreen() {
while (true) {
if (ajt = captureScreen()) {
return ajt;
break;
}
}
} //截图

while(true){sleep(1000);}

@卟db懂 你引用干啥 你不知道很难复制代码?我点全部复制还要把你的复制进去 然后慢慢删。
我%~#%$。。。

谢谢楼主分享
我弄了个简化版的
pat="/storage/emulated/0/DCIM/Screenshots/1.png"//图片地址
var a=getimgtext(pat);//返回信息
lo(a);
function getimgtext(path){
var url="http://pic.sogou.com/pic/upload_pic.jsp";
var res=http.postMultipart(url,{
"file": open(path),
});
var t=res.body.string();
res=http.get("http://pic.sogou.com/pic/ocr/ocrOnline.jsp?query="+t);
t=res.body.string();
return t;
}//通过搜狗ocr获取路径图片里的文字

  • 5
    帖子
  • 2370
    浏览

与 Auto.js 的连接断开,我们正在尝试重连,请耐心等待