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("没有找到");}