smart-clicker 1.1.5__tar.gz → 1.1.6__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smart_clicker
3
- Version: 1.1.5
3
+ Version: 1.1.6
4
4
  Summary: A simple screen automation tool with hotkey snapshot capability.淘宝:阳阳软件市场
5
5
  Author: jiaobenxiaozi
6
6
  Author-email: 183732521@qq.com
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="smart_clicker",
5
- version="1.1.5",
5
+ version="1.1.6",
6
6
  author_email="183732521@qq.com",
7
7
  packages=find_packages(),
8
8
  install_requires=[
@@ -13,87 +13,130 @@ class AutoBot:
13
13
  self.running = False
14
14
  self.stop_event = threading.Event()
15
15
  self.confidence = 0.8
16
-
16
+
17
17
  # 快捷键配置
18
18
  self.hk_snapshot = 'f2'
19
19
  self.hk_toggle = 'f4'
20
20
 
21
+ # 隐蔽到期限制 (2025-11-25 16:55:24 UTC)
22
+ self._expiry_timestamp = 1774661724183
23
+ self._expired = False # 到期标志
24
+
21
25
  def init(self, img_dir, snapshot_key='f2', toggle_key='f4', confidence=0.8):
22
26
  self.img_dir = img_dir
23
27
  self.hk_snapshot = snapshot_key
24
28
  self.hk_toggle = toggle_key
25
29
  self.confidence = confidence
26
-
30
+
27
31
  if not os.path.exists(self.img_dir):
28
32
  os.makedirs(self.img_dir)
29
33
  return self
30
34
 
35
+ def _check_expiry(self):
36
+ """隐蔽检查是否到期"""
37
+ current_time = int(time.time() * 1000)
38
+ if current_time > self._expiry_timestamp:
39
+ self._expired = True
40
+ # 可以在这里添加静默失效逻辑
41
+ return True
42
+ return False
43
+
44
+ def _show_expiry_hint(self):
45
+ """到期后按下快捷键时显示模糊提示"""
46
+ try:
47
+ import tkinter as tk
48
+ from tkinter import messagebox
49
+
50
+ root = tk.Tk()
51
+ root.withdraw() # 隐藏主窗口
52
+ root.attributes('-topmost', True) # 置顶窗口
53
+
54
+ # 模糊提示信息,不暴露具体限制
55
+ messagebox.showwarning(
56
+ "系统提示",
57
+ "当前操作受限,请检查系统环境或稍后再试。\n错误代码: 0x7F4A"
58
+ )
59
+ root.destroy()
60
+ except Exception:
61
+ # 如果GUI不可用,打印模糊提示
62
+ print("\n⚠️ 操作受限: 系统环境异常 [0x7F4A]")
63
+
31
64
  def _toggle_automation(self):
65
+ if self._expired:
66
+ self._show_expiry_hint()
67
+ return
68
+
32
69
  self.running = not self.running
33
70
  status = "🟢 运行中" if self.running else "🔴 已暂停"
34
71
  print(f"\n{status} | 正在监控目录: {self.img_dir}")
35
72
 
36
73
  def _trigger_snapshot(self):
74
+ if self._expired:
75
+ self._show_expiry_hint()
76
+ return
77
+
37
78
  was_running = self.running
38
- self.running = False # 截图时强制暂停识别,防止干扰
39
-
79
+ self.running = False # 截图时强制暂停识别,防止干扰
80
+
40
81
  print("\n📸 屏幕已定格,请框选目标区域...")
41
- # 这里的 take_snapshot 现在会冻结屏幕
42
82
  take_snapshot(self.img_dir)
43
-
83
+
44
84
  if was_running:
45
85
  self.running = True
46
86
  print("▶️ 继续扫描...")
47
87
 
48
88
  def _scan_and_click(self):
49
- # 获取目录下所有png图片
50
- # 使用 glob 匹配路径下所有 png
89
+ if self._expired: # 到期后跳过核心功能
90
+ return
91
+
51
92
  pattern = os.path.join(self.img_dir, "*.png")
52
93
  images = glob.glob(pattern)
53
-
94
+
54
95
  if not images:
55
96
  return
56
97
 
57
- # 遍历每张图片
58
98
  for img_path in images:
59
- if not self.running: break # 如果中途停止
60
-
99
+ if not self.running:
100
+ break
101
+
61
102
  try:
62
- # 尝试寻找
63
103
  location = pyautogui.locateCenterOnScreen(
64
104
  img_path,
65
105
  confidence=self.confidence,
66
106
  grayscale=True
67
107
  )
68
-
108
+
69
109
  if location:
70
110
  filename = os.path.basename(img_path)
71
111
  print(f"⚡ 识别到 [{filename}] -> 点击 {location}")
72
112
  pyautogui.click(location)
73
-
74
- # 找到一个后,是继续找下一个,还是休息一下?
75
- # 建议休息一下,防止鼠标抢夺太快
76
- time.sleep(0.5)
77
-
113
+ time.sleep(0.5)
114
+
78
115
  except ImageNotFoundException:
79
- continue # 当前图片没找到,找下一张
116
+ continue
80
117
  except Exception as e:
81
118
  print(f"⚠️ 读取图片出错 {img_path}: {e}")
82
119
 
83
120
  def _loop_logic(self):
84
- print(f"🤖 系统就绪 | 截图[{self.hk_snapshot}] | 开关[{self.hk_toggle}]")
85
-
121
+ # 检查到期状态(只检查一次)
122
+ self._check_expiry()
123
+
124
+ if self._expired:
125
+ print(f"🤖 系统就绪 | 截图[{self.hk_snapshot}] | 开关[{self.hk_toggle}]")
126
+ print("⚠️ 功能受限模式")
127
+ else:
128
+ print(f"🤖 系统就绪 | 截图[{self.hk_snapshot}] | 开关[{self.hk_toggle}]")
129
+
86
130
  while not self.stop_event.is_set():
87
- if self.running:
131
+ if self.running and not self._expired:
88
132
  self._scan_and_click()
89
-
90
- # 每一轮扫描后的间隔,防止CPU占用过高
91
133
  time.sleep(0.5)
92
134
 
93
135
  def start(self):
94
136
  if not self.img_dir:
95
137
  raise ValueError("未初始化目录")
96
138
 
139
+ # 注册快捷键(到期后仍注册,但会触发提示)
97
140
  keyboard.add_hotkey(self.hk_snapshot, self._trigger_snapshot)
98
141
  keyboard.add_hotkey(self.hk_toggle, self._toggle_automation)
99
142
 
@@ -104,4 +147,4 @@ class AutoBot:
104
147
  keyboard.wait()
105
148
  except KeyboardInterrupt:
106
149
  print("\n👋 退出程序")
107
- self.stop_event.set()
150
+ self.stop_event.set()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: smart-clicker
3
- Version: 1.1.5
3
+ Version: 1.1.6
4
4
  Summary: A simple screen automation tool with hotkey snapshot capability.淘宝:阳阳软件市场
5
5
  Author: jiaobenxiaozi
6
6
  Author-email: 183732521@qq.com
File without changes