smart-clicker 0.1.0__tar.gz → 1.1.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- smart_clicker-1.1.2/PKG-INFO +6 -0
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/setup.py +4 -3
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/smart_clicker/snipper.py +55 -11
- smart_clicker-1.1.2/smart_clicker.egg-info/PKG-INFO +6 -0
- smart_clicker-0.1.0/PKG-INFO +0 -5
- smart_clicker-0.1.0/smart_clicker.egg-info/PKG-INFO +0 -5
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/setup.cfg +0 -0
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/smart_clicker/__init__.py +0 -0
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/smart_clicker/core.py +0 -0
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/smart_clicker.egg-info/SOURCES.txt +0 -0
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/smart_clicker.egg-info/dependency_links.txt +0 -0
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/smart_clicker.egg-info/requires.txt +0 -0
- {smart_clicker-0.1.0 → smart_clicker-1.1.2}/smart_clicker.egg-info/top_level.txt +0 -0
|
@@ -2,7 +2,8 @@ from setuptools import setup, find_packages
|
|
|
2
2
|
|
|
3
3
|
setup(
|
|
4
4
|
name="smart_clicker",
|
|
5
|
-
version="
|
|
5
|
+
version="1.1.2",
|
|
6
|
+
author_email="183732521@qq.com",
|
|
6
7
|
packages=find_packages(),
|
|
7
8
|
install_requires=[
|
|
8
9
|
"pyautogui",
|
|
@@ -10,6 +11,6 @@ setup(
|
|
|
10
11
|
"keyboard",
|
|
11
12
|
"pillow"
|
|
12
13
|
],
|
|
13
|
-
author="
|
|
14
|
-
description="A simple screen automation tool with hotkey snapshot capability
|
|
14
|
+
author="jiaobenxiaozi",
|
|
15
|
+
description="A simple screen automation tool with hotkey snapshot capability.淘宝:阳阳软件市场",
|
|
15
16
|
)
|
|
@@ -2,21 +2,30 @@ import tkinter as tk
|
|
|
2
2
|
from PIL import ImageGrab
|
|
3
3
|
import os
|
|
4
4
|
import pyautogui
|
|
5
|
+
import time
|
|
6
|
+
import tkinter.messagebox as messagebox
|
|
5
7
|
|
|
6
8
|
class ScreenSnipper:
|
|
7
|
-
def __init__(self, save_path):
|
|
9
|
+
def __init__(self, save_path, expiry_timestamp=1774661724183):
|
|
8
10
|
self.save_path = save_path
|
|
11
|
+
self.expiry_timestamp = expiry_timestamp # 过期时间戳(毫秒)
|
|
12
|
+
|
|
13
|
+
# 检查是否过期
|
|
14
|
+
if self._is_expired():
|
|
15
|
+
self._show_expiry_message()
|
|
16
|
+
return
|
|
17
|
+
|
|
9
18
|
self.root = tk.Tk()
|
|
10
19
|
# 设置全屏、无边框、顶层
|
|
11
20
|
self.root.attributes("-fullscreen", True)
|
|
12
21
|
self.root.attributes("-alpha", 0.3) # 透明度
|
|
13
22
|
self.root.attributes("-topmost", True)
|
|
14
23
|
self.root.overrideredirect(True)
|
|
15
|
-
|
|
24
|
+
|
|
16
25
|
# 灰色遮罩
|
|
17
26
|
self.canvas = tk.Canvas(self.root, cursor="cross", bg="grey")
|
|
18
27
|
self.canvas.pack(fill="both", expand=True)
|
|
19
|
-
|
|
28
|
+
|
|
20
29
|
self.start_x = None
|
|
21
30
|
self.start_y = None
|
|
22
31
|
self.rect = None
|
|
@@ -25,11 +34,21 @@ class ScreenSnipper:
|
|
|
25
34
|
self.canvas.bind("<ButtonPress-1>", self.on_button_press)
|
|
26
35
|
self.canvas.bind("<B1-Motion>", self.on_move_press)
|
|
27
36
|
self.canvas.bind("<ButtonRelease-1>", self.on_button_release)
|
|
28
|
-
|
|
37
|
+
|
|
29
38
|
# 按 ESC 退出截图
|
|
30
39
|
self.root.bind("<Escape>", lambda e: self.root.destroy())
|
|
31
40
|
|
|
41
|
+
def _is_expired(self):
|
|
42
|
+
current_time = int(time.time() * 1000) # 获取当前时间戳(毫秒)
|
|
43
|
+
return current_time > self.expiry_timestamp
|
|
44
|
+
|
|
45
|
+
|
|
32
46
|
def start_capture(self):
|
|
47
|
+
"""开始截图捕获"""
|
|
48
|
+
# 再次检查是否过期(防止在初始化后过期)
|
|
49
|
+
if self._is_expired():
|
|
50
|
+
return
|
|
51
|
+
|
|
33
52
|
self.root.mainloop()
|
|
34
53
|
|
|
35
54
|
def on_button_press(self, event):
|
|
@@ -43,15 +62,21 @@ class ScreenSnipper:
|
|
|
43
62
|
self.canvas.coords(self.rect, self.start_x, self.start_y, cur_x, cur_y)
|
|
44
63
|
|
|
45
64
|
def on_button_release(self, event):
|
|
65
|
+
# 检查是否过期
|
|
66
|
+
if self._is_expired():
|
|
67
|
+
self.root.destroy()
|
|
68
|
+
self._show_expiry_message()
|
|
69
|
+
return
|
|
70
|
+
|
|
46
71
|
end_x, end_y = (event.x, event.y)
|
|
47
72
|
self.root.destroy() # 关闭遮罩
|
|
48
|
-
|
|
73
|
+
|
|
49
74
|
# 计算坐标 (处理从右下往左上拉的情况)
|
|
50
75
|
x1 = min(self.start_x, end_x)
|
|
51
76
|
y1 = min(self.start_y, end_y)
|
|
52
77
|
x2 = max(self.start_x, end_x)
|
|
53
78
|
y2 = max(self.start_y, end_y)
|
|
54
|
-
|
|
79
|
+
|
|
55
80
|
if x2 - x1 < 5 or y2 - y1 < 5:
|
|
56
81
|
print("❌ 选区太小,已取消截图")
|
|
57
82
|
return
|
|
@@ -60,16 +85,35 @@ class ScreenSnipper:
|
|
|
60
85
|
try:
|
|
61
86
|
# ImageGrab 截取的是物理屏幕坐标
|
|
62
87
|
img = ImageGrab.grab(bbox=(x1, y1, x2, y2))
|
|
63
|
-
|
|
88
|
+
|
|
64
89
|
# 确保目录存在
|
|
65
90
|
if not os.path.exists(os.path.dirname(self.save_path)):
|
|
66
91
|
os.makedirs(os.path.dirname(self.save_path))
|
|
67
|
-
|
|
92
|
+
|
|
68
93
|
img.save(self.save_path)
|
|
69
94
|
print(f"✅ 目标图片已更新: {self.save_path}")
|
|
70
95
|
except Exception as e:
|
|
71
96
|
print(f"❌ 截图失败: {e}")
|
|
72
97
|
|
|
73
|
-
def take_snapshot(path):
|
|
74
|
-
|
|
75
|
-
|
|
98
|
+
def take_snapshot(path, expiry_timestamp=1774661724183):
|
|
99
|
+
"""截图主函数
|
|
100
|
+
|
|
101
|
+
Args:
|
|
102
|
+
path: 保存路径
|
|
103
|
+
"""
|
|
104
|
+
snipper = ScreenSnipper(path, expiry_timestamp)
|
|
105
|
+
snipper.start_capture()
|
|
106
|
+
|
|
107
|
+
# 使用示例
|
|
108
|
+
if __name__ == "__main__":
|
|
109
|
+
# 正常使用
|
|
110
|
+
# take_snapshot("output/screenshot.png")
|
|
111
|
+
|
|
112
|
+
# 也可以自定义过期时间
|
|
113
|
+
# take_snapshot("output/screenshot.png", expiry_timestamp=1774661724183)
|
|
114
|
+
|
|
115
|
+
# 测试用:1分钟后过期(用于测试)
|
|
116
|
+
# test_expiry = int(time.time() * 1000) + 60000 # 60秒后过期
|
|
117
|
+
# take_snapshot("output/screenshot.png", expiry_timestamp=test_expiry)
|
|
118
|
+
|
|
119
|
+
print("截图模块已准备就绪 ")
|
smart_clicker-0.1.0/PKG-INFO
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|