admin 管理员组文章数量: 1184232
auto.js
颜色获取和检测
1.颜色获取和检测
if(!requestScreenCapture()){ toast("请求截图失败"); exit
}
sleep(2000);
var x = 456; var y = 456;
//获取在点(x, y)处的颜色
var c = images.pixel(captureScreen(), x, y);
//显示该颜色
var msg = "";
msg += "在位置(" + x + ", " + y + ")处的颜色为" + colors.toString(c);
msg += "\nR = " + colors.red(c) + ", G = " + colors.green(c) + ", B = " + colors.blue(c);
//检测在点(x, y)处是否有颜色#73bdb6 (模糊比较)
var isDetected = images.detectsColor(captureScreen(), "#73bdb6", x, y);
msg += "\n该位置是否匹配到颜色#73bdb6: " + isDetected;
alert(msg);
2.精确找色
if(!requestScreenCapture()){ toast("请求截图失败"); stop();
}
var img = captureScreen();
toastLog("开始找色");
//0x1d75b3为编辑器默认主题蓝色字体(if, var等关键字)的颜色 //找到颜色与0x1d75b3完全相等的颜色
var point = findColorEquals(img, 0x006699);
if(point){ toastLog("x = " + point.x + ", y = " + point.y);
}
else{toastLog("没有找到");
}
3.模糊找色
if(!requestScreenCapture()){ toast("请求截图失败"); exit();
}
var img = captureScreen();
//0xF70215为编辑器红色字体的颜色
toastLog("开始找色");
var point = findColor(img, 0xF60216);
if(point){ toastLog("x = " + point.x + ", y = " + point.y);
}
else{toastLog("没有找到");
}
4. 区域找色1
if(!requestScreenCapture()){ toast("请求截图失败"); exit();
}
var img = captureScreen();
toastLog("开始找色");
//指定在位置(100, 220)宽高为400*400的区域找色。
//#75438a是编辑器默认主题的棕红色字体(数字)颜色,位置大约在第5行的"2000",坐标大约为(283, 465)
var point = findColorInRegion(img, "#75438a", 90, 220, 900, 1000);
if(point){ toastLog("x = " + point.x + ", y = " + point.y);
}else{toastLog("没有找到");
}
4.区域找色2
if(!requestScreenCapture()){ toast("请求截图失败"); exit();
}
var img = captureScreen();
//0xffffff为白色 toastLog("开始找色");
//指定在位置(90, 220)宽高为900*1000的区域找色。
//0xff00cc是编辑器的深粉红色字体(字符串)颜色
var point = findColor(img, "#ff00cc", { region: [90, 220, 900, 1000], threads: 8
});
if(point){ toastLog("x = " + point.x + ", y = " + point.y);
}
else{toastLog("没有找到");
}
本文标签: autojs
版权声明:本文标题:auto.js 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://roclinux.cn/p/1700343490a405640.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论