94 lines
2.5 KiB
JavaScript
94 lines
2.5 KiB
JavaScript
// 等待获取无障碍权限
|
|
auto.waitFor()
|
|
|
|
// 设置脚本坐标点击所适合的屏幕宽高。如果脚本运行时,屏幕宽度不一致会自动放缩坐标。
|
|
setScreenMetrics(1080, 1920)
|
|
|
|
|
|
importClass(android.graphics.Paint);
|
|
Canvas = android.graphics.Canvas;
|
|
importClass(android.graphics.Bitmap);
|
|
|
|
function textpaint() {
|
|
var bitmap = Bitmap.createBitmap(600, 140, Bitmap.Config.ARGB_8888);
|
|
|
|
var canvas = new Canvas(bitmap);
|
|
//background-color
|
|
//(Alpha,Red,Green,Blue)
|
|
canvas.drawARGB(255, 0, 0, 0);
|
|
|
|
|
|
// var paint = new Paint();
|
|
|
|
// //圆盘背景???
|
|
// paint.setARGB(255, 0, 255, 0); //白色画笔
|
|
// paint.setStyle(Paint.Style.FILL); //空心样式
|
|
// paint.setFilterBitmap(true); //抗锯齿
|
|
// paint.setFakeBoldText(true); //加粗
|
|
// paint.setHinting(16); //字体微调
|
|
// paint.setTextSize(22);
|
|
// for (i = 0; i < str.length; i++) {
|
|
// // paint.setARGB(255, random(0, 255), random(0, 255), random(0, 255)); //眼睛快瞎了
|
|
// canvas.drawText(str[i], 0, (i + 1) * 25, paint);
|
|
// }
|
|
// // canvas.drawText(str, 0, (i + 1) * 25, paint);
|
|
|
|
canvas.save(Canvas.ALL_SAVE_FLAG);
|
|
canvas.restore();
|
|
|
|
return bitmap;
|
|
}
|
|
|
|
|
|
var window = floaty.window(
|
|
<frame>
|
|
<vertical>
|
|
/*circle="true",两端裁剪为circle,其他圆角风格可以参考https://easydoc.net/doc/84873548/LvEnNZ0d/DuI3kIia */
|
|
<img id="img" w="auto" h="auto" radiusBottomLeft="25" radiusBottomRight="25"/>
|
|
</vertical>
|
|
</frame>
|
|
);
|
|
|
|
window.img.setImageBitmap(textpaint());
|
|
window.setPosition(240, -100);
|
|
|
|
//记录按键被按下的时间以便判断长按等动作 疑似有点幽默了
|
|
var downTime;
|
|
window.img.setOnTouchListener(function (view, event) {
|
|
switch (event.getAction()) {
|
|
//手指落下
|
|
case event.ACTION_DOWN:
|
|
x = event.getRawX();
|
|
y = event.getRawY();
|
|
windowX = window.getX();
|
|
windowY = window.getY();
|
|
downTime = new Date().getTime();
|
|
return true;
|
|
//移动
|
|
case event.ACTION_MOVE:
|
|
//移动手指时调整悬浮窗位置
|
|
// window.setPosition(windowX + (event.getRawX() - x), windowY + (event.getRawY() - y));
|
|
return true;
|
|
//抬起
|
|
case event.ACTION_UP:
|
|
//手指弹起时如果偏移很小则判断为点击
|
|
if (Math.abs(event.getRawY() - y) < 5 && Math.abs(event.getRawX() - x) < 5) {
|
|
threads.start(function () {
|
|
onClick();
|
|
});
|
|
}
|
|
return true;
|
|
}
|
|
return true;
|
|
});
|
|
|
|
function onClick(){
|
|
// var str = prompt('kxnmsl')
|
|
toast('有病')
|
|
// exit()
|
|
}
|
|
|
|
while (true) {
|
|
sleep(1000);
|
|
}
|