forked from snailuncle/autojsDemo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path悬浮框自增按钮.js
66 lines (62 loc) · 1.65 KB
/
悬浮框自增按钮.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
var window = floaty.window(
<frame w="110">
<vertical >
<button id="action" text="点击拖动" style="Widget.AppCompat.Button.Colored"/>
<button id="end" text="结束" />
</vertical>
</frame>
);
setInterval(() => {}, 500);
var x = 0, y = 0;
var windowX, windowY;
window.action.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){
onClick();
}
return true;
}
sleep(10);
return true;
});
var numnum=0;
function onClick(str,sec){
numnum++;
显示状态信息(""+numnum,2);
}
var timerId;
function 显示状态信息(str,sec){
try {
clearTimeout(timerId);
}
catch (error) {
toastLog("error");
}
ui.run(()=>{
window.action.setText(str);
});
timerId=setTimeout(function(){
ui.run(()=>{
window.action.setText("");
});
}, sec*1000);
}
window.end.click(() => {
floaty.closeAll();
engines.stopAll();
exit();
});