Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -772,8 +772,18 @@ async def handle_action(ws: WebSocket, msg: dict, sess: dict):
|
|
| 772 |
return {"data": "", "width": 1920, "height": 1080, "mouse_x": 0, "mouse_y": 0}
|
| 773 |
|
| 774 |
async def shot_bg(label: str = "", delay: float = 0.5,
|
| 775 |
-
force_mx: int | None = None, force_my: int | None = None
|
| 776 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 777 |
await asyncio.sleep(delay)
|
| 778 |
now = time.time()
|
| 779 |
if now - sess.get("last_bg_shot_ts", 0) < 0.3:
|
|
@@ -781,25 +791,40 @@ async def handle_action(ws: WebSocket, msg: dict, sess: dict):
|
|
| 781 |
|
| 782 |
result = await _safe_capture(0.65, 72, force_mx, force_my)
|
| 783 |
sess["last_bg_shot_ts"] = time.time()
|
| 784 |
-
if
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
| 798 |
-
|
| 799 |
-
|
| 800 |
-
|
| 801 |
-
|
| 802 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 803 |
|
| 804 |
async def shot_explicit(label: str = ""):
|
| 805 |
"""screenshot ุตุฑูุญ โ ููุฑุณู ุฏุงุฆู
ุงู ุจุฏูู delta suppressionุ ููู ุฃููููุฉ ู
ุทููุฉ
|
|
@@ -875,7 +900,7 @@ async def handle_action(ws: WebSocket, msg: dict, sess: dict):
|
|
| 875 |
await xdo(["click", btn], display)
|
| 876 |
btn_name = {"1": "left", "2": "middle", "3": "right"}.get(btn, "left")
|
| 877 |
await send({"type": "ack", "action": "mouse_click", "x": x, "y": y, "button": btn_name})
|
| 878 |
-
asyncio.create_task(shot_bg(f"click {btn_name} ({x},{y})", delay=0.5, force_mx=x, force_my=y))
|
| 879 |
|
| 880 |
# โโ mouse_drag โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 881 |
elif action == "mouse_drag":
|
|
|
|
| 772 |
return {"data": "", "width": 1920, "height": 1080, "mouse_x": 0, "mouse_y": 0}
|
| 773 |
|
| 774 |
async def shot_bg(label: str = "", delay: float = 0.5,
|
| 775 |
+
force_mx: int | None = None, force_my: int | None = None,
|
| 776 |
+
extra_shot_delay: float | None = None):
|
| 777 |
+
"""
|
| 778 |
+
auto_shot ูู ุงูุฎูููุฉ โ ู
ุน rate limit + delta suppression.
|
| 779 |
+
ุฅุฐุง ุชู
ุชู
ุฑูุฑ extra_shot_delayุ ุชูุฑุณู ููุทุฉ ุซุงููุฉ ุฅุถุงููุฉ ุจุนุฏ ุฐูู ุงูุชุฃุฎูุฑ
|
| 780 |
+
ุงูุฅุถุงูู (ู
ุญุณูุจุงู ู
ู ููุช ุงูุชูุงุก ุงูููุทุฉ ุงูุฃููู) โ ูุฐุง ูุบุทู ุญุงูุฉ ุงูููุฑ ุนูู
|
| 781 |
+
ุฑุงุจุท ูููู ูุตูุญุฉ ุฌุฏูุฏุฉ ูุฏ ูุง ุชูุชู
ู ุชุญู
ูููุง ุฎูุงู ุงูุชุฃุฎูุฑ ุงูุฃููู ุงููุตูุฑ
|
| 782 |
+
(ู
ุซูุงู ุตูุญุฉ ุจุทูุฆุฉ ุนูู ุณูุฑูุฑ ู
ุญุฏูุฏ ุงูู
ูุงุฑุฏ)ุ ุฏูู ุงูุญุงุฌุฉ ูู
ุนุฑูุฉ ู
ุณุจูุฉ ุจููุน
|
| 783 |
+
ุงูุนูุตุฑ ุงูู
ูููุฑ ุนููู. ุชุชุฌุงูู delta suppression ููุฐู ุงูููุทุฉ ุงูุซุงููุฉ ุชุญุฏูุฏุงู
|
| 784 |
+
ูุฃู ุงูู
ุญุชูู ู
ุชููุน ุฃู ูููู ู
ุฎุชููุงู (ุตูุญุฉ ุชุญู
ููุช ุฃูุซุฑ) ุญุชู ูู ุชุดุงุจู ุงูู hash
|
| 785 |
+
ุฌุฒุฆูุงู ู
ุน ุฎูููุฉ ู
ุดุงุจูุฉ.
|
| 786 |
+
"""
|
| 787 |
await asyncio.sleep(delay)
|
| 788 |
now = time.time()
|
| 789 |
if now - sess.get("last_bg_shot_ts", 0) < 0.3:
|
|
|
|
| 791 |
|
| 792 |
result = await _safe_capture(0.65, 72, force_mx, force_my)
|
| 793 |
sess["last_bg_shot_ts"] = time.time()
|
| 794 |
+
if result["data"]:
|
| 795 |
+
fh = _frame_hash(result["data"])
|
| 796 |
+
if fh != sess.get("last_bg_hash", ""):
|
| 797 |
+
sess["last_bg_hash"] = fh
|
| 798 |
+
await send({
|
| 799 |
+
"type": "screenshot",
|
| 800 |
+
"data": result["data"],
|
| 801 |
+
"ts": int(time.time() * 1000),
|
| 802 |
+
"auto": True, "label": label,
|
| 803 |
+
"screen_width": result["width"],
|
| 804 |
+
"screen_height": result["height"],
|
| 805 |
+
"mouse_x": result["mouse_x"],
|
| 806 |
+
"mouse_y": result["mouse_y"],
|
| 807 |
+
"has_grid": True,
|
| 808 |
+
})
|
| 809 |
+
|
| 810 |
+
if extra_shot_delay:
|
| 811 |
+
await asyncio.sleep(extra_shot_delay)
|
| 812 |
+
result2 = await _safe_capture(0.65, 72, force_mx, force_my)
|
| 813 |
+
sess["last_bg_shot_ts"] = time.time()
|
| 814 |
+
if result2["data"]:
|
| 815 |
+
fh2 = _frame_hash(result2["data"])
|
| 816 |
+
sess["last_bg_hash"] = fh2
|
| 817 |
+
await send({
|
| 818 |
+
"type": "screenshot",
|
| 819 |
+
"data": result2["data"],
|
| 820 |
+
"ts": int(time.time() * 1000),
|
| 821 |
+
"auto": True, "label": f"{label} (delayed)",
|
| 822 |
+
"screen_width": result2["width"],
|
| 823 |
+
"screen_height": result2["height"],
|
| 824 |
+
"mouse_x": result2["mouse_x"],
|
| 825 |
+
"mouse_y": result2["mouse_y"],
|
| 826 |
+
"has_grid": True,
|
| 827 |
+
})
|
| 828 |
|
| 829 |
async def shot_explicit(label: str = ""):
|
| 830 |
"""screenshot ุตุฑูุญ โ ููุฑุณู ุฏุงุฆู
ุงู ุจุฏูู delta suppressionุ ููู ุฃููููุฉ ู
ุทููุฉ
|
|
|
|
| 900 |
await xdo(["click", btn], display)
|
| 901 |
btn_name = {"1": "left", "2": "middle", "3": "right"}.get(btn, "left")
|
| 902 |
await send({"type": "ack", "action": "mouse_click", "x": x, "y": y, "button": btn_name})
|
| 903 |
+
asyncio.create_task(shot_bg(f"click {btn_name} ({x},{y})", delay=0.5, force_mx=x, force_my=y, extra_shot_delay=3.0))
|
| 904 |
|
| 905 |
# โโ mouse_drag โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
| 906 |
elif action == "mouse_drag":
|