ascript 1.3.27__py3-none-win_amd64.whl

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.
Files changed (177) hide show
  1. ascript/__init__.py +8 -0
  2. ascript/hooks/__init__.py +0 -0
  3. ascript/hooks/hook-ascript.py +2 -0
  4. ascript/windows/__init__.py +29 -0
  5. ascript/windows/daos/__init__.py +0 -0
  6. ascript/windows/daos/screen.py +143 -0
  7. ascript/windows/hardware/__init__.py +5 -0
  8. ascript/windows/hardware/keyboard.py +279 -0
  9. ascript/windows/hardware/logitech_driver.py +179 -0
  10. ascript/windows/hardware/mouse.py +308 -0
  11. ascript/windows/license/__init__.py +16 -0
  12. ascript/windows/license/achttp.cp310-win_amd64.pyd +0 -0
  13. ascript/windows/license/achttp.cp311-win_amd64.pyd +0 -0
  14. ascript/windows/license/achttp.cp312-win_amd64.pyd +0 -0
  15. ascript/windows/license/achttp.cp313-win_amd64.pyd +0 -0
  16. ascript/windows/license/achttp.cp314-win_amd64.pyd +0 -0
  17. ascript/windows/license/achttp.cp38-win_amd64.pyd +0 -0
  18. ascript/windows/license/achttp.cp39-win_amd64.pyd +0 -0
  19. ascript/windows/media/__init__.py +0 -0
  20. ascript/windows/resources/__init__.py +0 -0
  21. ascript/windows/resources/libs/logitech/x64/LogitechGkeyEnginesWrapper.dll +0 -0
  22. ascript/windows/resources/libs/logitech/x86/LogitechGkeyEnginesWrapper.dll +0 -0
  23. ascript/windows/resources/templates/__init__.py +0 -0
  24. ascript/windows/resources/templates/__init__py.win.template +51 -0
  25. ascript/windows/resources/templates/build.as.win.template +14 -0
  26. ascript/windows/resources/templates/build.py +71 -0
  27. ascript/windows/resources/templates/logo_windows.ico +0 -0
  28. ascript/windows/resources/templates/windows/main.py +50 -0
  29. ascript/windows/resources/templates/windows/pyproject.toml +44 -0
  30. ascript/windows/resources/templates/windows/res/img/logo.ico +0 -0
  31. ascript/windows/screen/__init__.py +13 -0
  32. ascript/windows/screen/as_cv.py +382 -0
  33. ascript/windows/screen/canny.py +128 -0
  34. ascript/windows/screen/code_scanner.py +72 -0
  35. ascript/windows/screen/color_algorithms.py +277 -0
  36. ascript/windows/screen/find_colors.py +251 -0
  37. ascript/windows/screen/find_images.py +217 -0
  38. ascript/windows/screen/ocr/__init__.py +4 -0
  39. ascript/windows/screen/ocr/ocr.py +223 -0
  40. ascript/windows/screen/ocr/rapidocr_hook.py +301 -0
  41. ascript/windows/screen/ocrx.py +169 -0
  42. ascript/windows/screen/screen_core.py +139 -0
  43. ascript/windows/store/__init__.py +21 -0
  44. ascript/windows/system/__init__.py +8 -0
  45. ascript/windows/system/device.py +355 -0
  46. ascript/windows/system/easy_print.py +115 -0
  47. ascript/windows/system/env.py +492 -0
  48. ascript/windows/system/exception/__init__.py +1 -0
  49. ascript/windows/system/key_value.py +145 -0
  50. ascript/windows/system/pip.py +175 -0
  51. ascript/windows/system/r.py +165 -0
  52. ascript/windows/system/runtime.py +62 -0
  53. ascript/windows/tools/__init__.py +27 -0
  54. ascript/windows/tools/__main__.py +21 -0
  55. ascript/windows/tools/action.json +33 -0
  56. ascript/windows/tools/action.py +168 -0
  57. ascript/windows/tools/colors_tool.py +391 -0
  58. ascript/windows/tools/config.py +26 -0
  59. ascript/windows/tools/dumptool.py +18 -0
  60. ascript/windows/tools/eel_api.py +495 -0
  61. ascript/windows/tools/gpplug/__init__.py +0 -0
  62. ascript/windows/tools/gpplug/plug.py +70 -0
  63. ascript/windows/tools/mouse_catch.py +168 -0
  64. ascript/windows/tools/plug_manager.py +38 -0
  65. ascript/windows/tools/tool_api.py +906 -0
  66. ascript/windows/tools/tool_window.py +56 -0
  67. ascript/windows/tools/uia_worker.py +365 -0
  68. ascript/windows/tools/web/app_store_window.html +481 -0
  69. ascript/windows/tools/web/colors.html +532 -0
  70. ascript/windows/tools/web/css/screen.css +1342 -0
  71. ascript/windows/tools/web/css/viewtree.css +357 -0
  72. ascript/windows/tools/web/flot_control.html +195 -0
  73. ascript/windows/tools/web/img/ico/favicon.png +0 -0
  74. ascript/windows/tools/web/img/ico/paintpalette.png +0 -0
  75. ascript/windows/tools/web/img/svg/find_colors.svg +1 -0
  76. ascript/windows/tools/web/img/svg/find_images.svg +1 -0
  77. ascript/windows/tools/web/img/svg/illustration-6.svg +89 -0
  78. ascript/windows/tools/web/img/svg/img_default.svg +1 -0
  79. ascript/windows/tools/web/img/svg/ocr.svg +1 -0
  80. ascript/windows/tools/web/js/screen/colors.js +466 -0
  81. ascript/windows/tools/web/js/screen/gp_plug.js +108 -0
  82. ascript/windows/tools/web/js/screen/image_mouse.js +464 -0
  83. ascript/windows/tools/web/js/screen/img_view.js +558 -0
  84. ascript/windows/tools/web/js/screen/plug.js +246 -0
  85. ascript/windows/tools/web/js/screen/screen.js +690 -0
  86. ascript/windows/tools/web/js/screen/screen_api.js +778 -0
  87. ascript/windows/tools/web/js/screen/screen_maker.js +10 -0
  88. ascript/windows/tools/web/js/utils/map.js +73 -0
  89. ascript/windows/tools/web/js/utils/upload.js +157 -0
  90. ascript/windows/tools/web/js/viewtree/niv_js.js +27 -0
  91. ascript/windows/tools/web/js/viewtree/vtree.js +1510 -0
  92. ascript/windows/tools/web/libs/bootstrap/css/bootstrap.min.css +6 -0
  93. ascript/windows/tools/web/libs/bootstrap/js/bootstrap.bundle.min.js +7 -0
  94. ascript/windows/tools/web/libs/bootstrap-icons/0-circle.svg +4 -0
  95. ascript/windows/tools/web/libs/bootstrap-icons/0-square.svg +4 -0
  96. ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.css +2078 -0
  97. ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.json +2052 -0
  98. ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.min.css +5 -0
  99. ascript/windows/tools/web/libs/bootstrap-icons/font/bootstrap-icons.scss +2090 -0
  100. ascript/windows/tools/web/libs/bootstrap-icons/font/fonts/bootstrap-icons.woff +0 -0
  101. ascript/windows/tools/web/libs/bootstrap-icons/font/fonts/bootstrap-icons.woff2 +0 -0
  102. ascript/windows/tools/web/libs/feather-icons/dist/feather.min.js +13 -0
  103. ascript/windows/tools/web/libs/feather-icons/dist/icons.json +1 -0
  104. ascript/windows/tools/web/libs/jquery/core.js +399 -0
  105. ascript/windows/tools/web/libs/jquery/jquery.js +10598 -0
  106. ascript/windows/tools/web/libs/jquery/jquery.min.js +4 -0
  107. ascript/windows/tools/web/libs/jquery/jquery.min.js.zip +0 -0
  108. ascript/windows/tools/web/libs/jquery/jquery.slim.js +8495 -0
  109. ascript/windows/tools/web/libs/jquery/jquery.slim.min.js +2 -0
  110. ascript/windows/tools/web/libs/jquery-menu/jquery.contextMenu.js +2134 -0
  111. ascript/windows/tools/web/libs/jquery-menu/jquery.contextMenu.min.css +16 -0
  112. ascript/windows/tools/web/libs/jquery-zTree/css/zTreeStyle.css +97 -0
  113. ascript/windows/tools/web/libs/jquery-zTree/img/diy/1_close.png +0 -0
  114. ascript/windows/tools/web/libs/jquery-zTree/img/diy/1_open.png +0 -0
  115. ascript/windows/tools/web/libs/jquery-zTree/img/diy/2.png +0 -0
  116. ascript/windows/tools/web/libs/jquery-zTree/img/diy/3.png +0 -0
  117. ascript/windows/tools/web/libs/jquery-zTree/img/diy/4.png +0 -0
  118. ascript/windows/tools/web/libs/jquery-zTree/img/diy/5.png +0 -0
  119. ascript/windows/tools/web/libs/jquery-zTree/img/diy/6.png +0 -0
  120. ascript/windows/tools/web/libs/jquery-zTree/img/diy/7.png +0 -0
  121. ascript/windows/tools/web/libs/jquery-zTree/img/diy/8.png +0 -0
  122. ascript/windows/tools/web/libs/jquery-zTree/img/diy/9.png +0 -0
  123. ascript/windows/tools/web/libs/jquery-zTree/img/line_conn.gif +0 -0
  124. ascript/windows/tools/web/libs/jquery-zTree/img/loading.gif +0 -0
  125. ascript/windows/tools/web/libs/jquery-zTree/img/tree-node-btn.png +0 -0
  126. ascript/windows/tools/web/libs/jquery-zTree/img/zTreeStandard.gif +0 -0
  127. ascript/windows/tools/web/libs/jquery-zTree/img/zTreeStandard.png +0 -0
  128. ascript/windows/tools/web/libs/jquery-zTree/js/jquery.ztree.all.min.js +3 -0
  129. ascript/windows/tools/web/libs/treeview/css/jquery.treeview.css +79 -0
  130. ascript/windows/tools/web/libs/treeview/img/file.png +0 -0
  131. ascript/windows/tools/web/libs/treeview/img/ico_loading.png +0 -0
  132. ascript/windows/tools/web/libs/treeview/img/icon4.png +0 -0
  133. ascript/windows/tools/web/libs/treeview/img/icon5.png +0 -0
  134. ascript/windows/tools/web/libs/treeview/img/icon6.png +0 -0
  135. ascript/windows/tools/web/libs/treeview/img/py.png +0 -0
  136. ascript/windows/tools/web/libs/treeview/img/treeview-black-line.gif +0 -0
  137. ascript/windows/tools/web/libs/treeview/img/treeview-black.gif +0 -0
  138. ascript/windows/tools/web/libs/treeview/img/treeview-default-line.gif +0 -0
  139. ascript/windows/tools/web/libs/treeview/img/treeview-default.gif +0 -0
  140. ascript/windows/tools/web/libs/treeview/img/treeview-famfamfam-line.gif +0 -0
  141. ascript/windows/tools/web/libs/treeview/img/treeview-famfamfam.gif +0 -0
  142. ascript/windows/tools/web/libs/treeview/img/treeview-gray-line.gif +0 -0
  143. ascript/windows/tools/web/libs/treeview/img/treeview-gray.gif +0 -0
  144. ascript/windows/tools/web/libs/treeview/img/treeview-red-line.gif +0 -0
  145. ascript/windows/tools/web/libs/treeview/img/treeview-red.gif +0 -0
  146. ascript/windows/tools/web/libs/treeview/js/jquery.treeview.edit.js +37 -0
  147. ascript/windows/tools/web/libs/treeview/js/jquery.treeview.js +250 -0
  148. ascript/windows/tools/web/license_window.html +255 -0
  149. ascript/windows/tools/web/plugs/a.html +653 -0
  150. ascript/windows/tools/web/plugs/demo.html +52 -0
  151. ascript/windows/tools/web/plugs/find_colors.html +629 -0
  152. ascript/windows/tools/web/plugs/find_images.html +699 -0
  153. ascript/windows/tools/web/plugs/rapidocr.html +954 -0
  154. ascript/windows/tools/web/vtree.html +496 -0
  155. ascript/windows/tools/webview/assets/index-HymBPl-I.css +1 -0
  156. ascript/windows/tools/webview/assets/index-PqA_m8tL.js +17 -0
  157. ascript/windows/tools/webview/index.html +13 -0
  158. ascript/windows/ui/__init__.py +6 -0
  159. ascript/windows/ui/app_store_window.py +272 -0
  160. ascript/windows/ui/draw_window.py +231 -0
  161. ascript/windows/ui/flot_test.py +297 -0
  162. ascript/windows/ui/flot_window.py +488 -0
  163. ascript/windows/ui/license_window.py +111 -0
  164. ascript/windows/ui/web_window.py +466 -0
  165. ascript/windows/utils/__init__.py +0 -0
  166. ascript/windows/utils/node_utils.py +20 -0
  167. ascript/windows/utils/screen_utils.py +280 -0
  168. ascript/windows/window/Selector.py +1015 -0
  169. ascript/windows/window/Window.py +747 -0
  170. ascript/windows/window/__init__.py +5 -0
  171. ascript/windows/window/launcher.py +213 -0
  172. ascript/windows/window/uia_runtime.py +26 -0
  173. ascript-1.3.27.dist-info/METADATA +41 -0
  174. ascript-1.3.27.dist-info/RECORD +177 -0
  175. ascript-1.3.27.dist-info/WHEEL +5 -0
  176. ascript-1.3.27.dist-info/entry_points.txt +2 -0
  177. ascript-1.3.27.dist-info/top_level.txt +1 -0
@@ -0,0 +1,629 @@
1
+ <!DOCTYPE html>
2
+ <html lang="zh-CN">
3
+
4
+ <head>
5
+ <meta charset="UTF-8">
6
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
7
+ <title>FindColors Pro v3.0</title>
8
+ <script>
9
+ (function () {
10
+ // 立即检测系统主题
11
+ const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches;
12
+ const theme = isDark ? 'dark' : 'light';
13
+
14
+ // 在页面还没渲染 Body 之前,就给 html 加上主题属性
15
+ document.documentElement.setAttribute('data-bs-theme', theme);
16
+
17
+ // 预设背景色,防止内容加载延迟时的白底
18
+ document.documentElement.style.backgroundColor = isDark ? '#212529' : '#ffffff';
19
+ })();
20
+ </script>
21
+ <link href="../libs/bootstrap/css/bootstrap.min.css" rel="stylesheet">
22
+ <link href="../libs/bootstrap-icons/font/bootstrap-icons.css" rel="stylesheet">
23
+ <style>
24
+ :root {
25
+ --editor-bg: #1e1e1e;
26
+ --panel-bg: #252526;
27
+ --border-color: #333;
28
+ --accent-color: #007acc;
29
+ --input-bg: #3c3c3c;
30
+ --text-main: #cccccc;
31
+ --header-height: 34px;
32
+ }
33
+
34
+ ::-webkit-scrollbar {
35
+ width: 4px;
36
+ height: 4px;
37
+ }
38
+
39
+ ::-webkit-scrollbar-thumb {
40
+ background: #444;
41
+ border-radius: 2px;
42
+ }
43
+
44
+ body,
45
+ html {
46
+ height: 100vh;
47
+ margin: 0;
48
+ font-size: 13px;
49
+ overflow: hidden;
50
+ background: var(--editor-bg);
51
+ color: var(--text-main);
52
+ font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
53
+ }
54
+
55
+ .main-layout {
56
+ display: flex;
57
+ height: 100vh;
58
+ width: 100%;
59
+ }
60
+
61
+ /* 左右 50/50 比例 */
62
+ .interaction-panel {
63
+ width: 50%;
64
+ display: flex;
65
+ flex-direction: column;
66
+ border-right: 1px solid var(--border-color);
67
+ background: var(--panel-bg);
68
+ }
69
+
70
+ .code-panel {
71
+ width: 50%;
72
+ display: flex;
73
+ flex-direction: column;
74
+ background: var(--editor-bg);
75
+ }
76
+
77
+ .module-header {
78
+ height: var(--header-height);
79
+ padding: 0 12px;
80
+ background: #2d2d2d;
81
+ color: #888;
82
+ font-size: 11px;
83
+ font-weight: bold;
84
+ display: flex;
85
+ justify-content: space-between;
86
+ align-items: center;
87
+ border-bottom: 1px solid var(--border-color);
88
+ }
89
+
90
+ /* 模块布局比例控制 */
91
+ .color-list {
92
+ flex: 0 0 auto;
93
+ max-height: 38%;
94
+ overflow-y: auto;
95
+ padding: 6px;
96
+ background: var(--editor-bg);
97
+ }
98
+
99
+ .config-area {
100
+ flex: 0 0 auto;
101
+ padding: 10px 12px;
102
+ background: var(--panel-bg);
103
+ border-bottom: 1px solid var(--border-color);
104
+ }
105
+
106
+ .results-panel {
107
+ flex: 1;
108
+ display: flex;
109
+ flex-direction: column;
110
+ min-height: 0;
111
+ }
112
+
113
+ .results-list {
114
+ flex: 1;
115
+ overflow-y: auto;
116
+ background: #1a1a1a;
117
+ }
118
+
119
+ /* 取色槽位条目优化 */
120
+ .color-row {
121
+ display: flex;
122
+ align-items: center;
123
+ gap: 10px;
124
+ padding: 6px 12px;
125
+ background: #2d2d2d;
126
+ border: 1px solid #3c3c3c;
127
+ margin-bottom: 3px;
128
+ border-radius: 4px;
129
+ }
130
+
131
+ .color-row.active {
132
+ border-left: 3px solid var(--accent-color);
133
+ background: #37373d;
134
+ }
135
+
136
+ .c-index {
137
+ width: 12px;
138
+ font-size: 11px;
139
+ color: #569cd6;
140
+ font-weight: bold;
141
+ }
142
+
143
+ .c-preview {
144
+ width: 16px;
145
+ height: 16px;
146
+ border-radius: 3px;
147
+ flex-shrink: 0;
148
+ border: 1px solid #555;
149
+ }
150
+
151
+ .c-hex {
152
+ font-family: 'Consolas';
153
+ font-size: 12px;
154
+ color: #ce9178;
155
+ }
156
+
157
+ .c-pos {
158
+ color: #858585;
159
+ font-size: 11px;
160
+ }
161
+
162
+ /* 删除按钮:移至右侧并加大 */
163
+ .btn-del-row {
164
+ margin-left: auto;
165
+ cursor: pointer;
166
+ color: #666;
167
+ font-size: 16px;
168
+ /* 增大图标 */
169
+ transition: color 0.2s;
170
+ display: flex;
171
+ align-items: center;
172
+ }
173
+
174
+ .btn-del-row:hover {
175
+ color: #f44336;
176
+ }
177
+
178
+ /* 配置项强制单行对齐 */
179
+ .config-item {
180
+ display: flex;
181
+ align-items: center;
182
+ margin-bottom: 8px;
183
+ gap: 10px;
184
+ }
185
+
186
+ .config-label {
187
+ flex: 0 0 70px;
188
+ color: #bbb;
189
+ font-size: 12px;
190
+ white-space: nowrap;
191
+ }
192
+
193
+ .config-control-wrap {
194
+ flex: 1;
195
+ display: flex;
196
+ align-items: center;
197
+ }
198
+
199
+ .input-group-custom {
200
+ display: flex !important;
201
+ flex-wrap: nowrap !important;
202
+ width: 100%;
203
+ }
204
+
205
+ .form-control-vs {
206
+ flex: 1;
207
+ background: var(--input-bg);
208
+ border: 1px solid #454545;
209
+ color: #eee;
210
+ font-size: 12px;
211
+ padding: 3px 8px;
212
+ border-radius: 3px;
213
+ }
214
+
215
+ /* 结果与代码显示 */
216
+ .res-item {
217
+ padding: 5px 12px;
218
+ border-bottom: 1px solid #222;
219
+ font-family: 'Consolas';
220
+ font-size: 11px;
221
+ color: #9cdcfe;
222
+ }
223
+
224
+ .code-display {
225
+ flex: 1;
226
+ padding: 15px;
227
+ font-family: 'Consolas', monospace;
228
+ color: #d4d4d4;
229
+ font-size: 13px;
230
+ line-height: 1.5;
231
+ overflow-y: auto;
232
+ white-space: pre-wrap !important;
233
+ word-break: break-all !important;
234
+ }
235
+
236
+ .btn-del-mini {
237
+ cursor: pointer;
238
+ color: #555;
239
+ }
240
+
241
+ .btn-del-mini:hover {
242
+ color: #f44336;
243
+ }
244
+
245
+ /* 列表项基础样式 */
246
+ .res-item {
247
+ padding: 8px 12px;
248
+ border-bottom: 1px solid rgba(255, 255, 255, 0.05);
249
+ transition: all 0.2s ease;
250
+ cursor: pointer;
251
+ display: flex;
252
+ align-items: center;
253
+ }
254
+
255
+ /* 鼠标覆盖时的样式:变亮并有左侧边框提示 */
256
+ .res-item:hover {
257
+ background: rgba(255, 255, 255, 0.1);
258
+ border-left: 3px solid #0d6efd;
259
+ /* 蓝色条 */
260
+ padding-left: 9px;
261
+ /* 抵消边框宽度,防止文字跳动 */
262
+ }
263
+
264
+ /* 序号样式 */
265
+ .res-item .label-tag {
266
+ background: rgba(13, 110, 253, 0.2);
267
+ color: #0d6efd;
268
+ padding: 2px 6px;
269
+ border-radius: 4px;
270
+ font-size: 11px;
271
+ font-weight: bold;
272
+ min-width: 35px;
273
+ text-align: center;
274
+ }
275
+ </style>
276
+ </head>
277
+
278
+ <body>
279
+
280
+ <div class="main-layout">
281
+ <div class="interaction-panel">
282
+ <div class="module-header">
283
+ <span>取色数据槽位 (1-0)</span>
284
+ <i class="bi bi-trash-fill btn-del-mini" onclick="clearAllSlots()" title="清空全部"></i>
285
+ </div>
286
+ <div class="color-list" id="slot-container"></div>
287
+
288
+ <div class="module-header">配置参数</div>
289
+ <div class="config-area">
290
+ <div class="config-item">
291
+ <span class="config-label">搜索范围</span>
292
+ <div class="config-control-wrap">
293
+ <div class="input-group-custom">
294
+ <input type="text" id="input-rect" class="form-control-vs" readonly placeholder="全屏模式"
295
+ style="border-top-right-radius:0; border-bottom-right-radius:0;">
296
+ <button class="btn btn-dark btn-sm border-secondary"
297
+ style="border-top-left-radius:0; border-bottom-left-radius:0;" onclick="clearRect()">
298
+ <i class="bi bi-x"></i>
299
+ </button>
300
+ </div>
301
+ </div>
302
+ </div>
303
+
304
+ <div class="config-item">
305
+ <span class="config-label">相似阈值</span>
306
+ <div class="config-control-wrap">
307
+ <input type="number" id="threshold" class="form-control-vs" value="0.95" step="0.05">
308
+ </div>
309
+ </div>
310
+
311
+ <div class="config-item">
312
+ <span class="config-label">排它间隔</span>
313
+ <div class="config-control-wrap">
314
+ <input type="number" id="exclusion_radius" class="form-control-vs" value="5" step="1">
315
+ </div>
316
+ </div>
317
+
318
+ <div class="config-item">
319
+ <span class="config-label">查找方向</span>
320
+ <div class="config-control-wrap">
321
+ <select id="select-ori" class="form-control-vs">
322
+ <option value="2">左上 → 右下 (垂直优先)</option>
323
+ <option value="1">左上 → 右下 (水平优先)</option>
324
+ <option value="3">右上 → 左下 (水平优先)</option>
325
+ <option value="4">右上 → 左下 (垂直优先)</option>
326
+ <option value="5">左下 → 右上 (垂直优先)</option>
327
+ <option value="6">左下 → 右上 (水平优先)</option>
328
+ <option value="7">右下 → 左上 (水平优先)</option>
329
+ <option value="8">右下 → 左上 (垂直优先)</option>
330
+ </select>
331
+ </div>
332
+ </div>
333
+
334
+ <div class="config-item">
335
+ <span class="config-label">查找多个</span>
336
+ <div class="ms-auto">
337
+ <div class="form-check form-switch m-0 p-0">
338
+ <input class="form-check-input" type="checkbox" id="check-multi" checked
339
+ style="cursor: pointer;">
340
+ </div>
341
+ </div>
342
+ </div>
343
+
344
+ <button class="btn btn-primary btn-sm w-100 mt-1 py-2" id="btn-test" onclick="runTest()">
345
+ <span id="btn-content"><i class="bi bi-play-fill me-1"></i> 执行测试找色</span>
346
+ </button>
347
+ </div>
348
+
349
+ <div class="results-panel">
350
+ <div class="module-header">
351
+ <div>找色结果 <span class="badge bg-dark ms-1" id="res-count">0</span></div>
352
+ <i class="bi bi-trash-fill btn-del-mini" onclick="clearResults()" title="清空结果"></i>
353
+ </div>
354
+ <div class="results-list" id="res-list">
355
+ <div class="text-center opacity-25 mt-4 small">等待运行测试...</div>
356
+ </div>
357
+ </div>
358
+ </div>
359
+
360
+ <div class="code-panel">
361
+ <div class="module-header">
362
+ <span>PYTHON 脚本预览</span>
363
+ <button id="copy_code" class="btn btn-dark btn-sm border-secondary text-secondary py-0"
364
+ style="font-size: 10px;" onclick="copyCode()">
365
+ <i class="bi bi-clipboard me-1"></i> COPY
366
+ </button>
367
+ </div>
368
+ <div class="code-display" id="code-box"></div>
369
+ </div>
370
+ </div>
371
+
372
+ <script src="../libs/jquery/jquery.min.js"></script>
373
+ <script>
374
+ let colorPoints = {};
375
+ let currentRect = null;
376
+
377
+ function initSlots() {
378
+ const container = $('#slot-container');
379
+ for (let i = 1; i <= 10; i++) {
380
+ let k = i === 10 ? "0" : i.toString();
381
+ container.append(`
382
+ <div class="color-row" id="row-${k}">
383
+ <span class="c-index">${k}</span>
384
+ <div class="c-preview" id="pre-${k}"></div>
385
+ <span class="c-hex" id="hex-${k}">--</span>
386
+ <span class="c-pos" id="pos-${k}">--</span>
387
+ <i class="bi bi-x btn-del-row" onclick="clearSlot('${k}')" title="移除此项"></i>
388
+ </div>`);
389
+ }
390
+ }
391
+
392
+ async function runTest() {
393
+
394
+ const keys = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
395
+ let colorStrings = [];
396
+ keys.forEach(k => { if (colorPoints[k]) colorStrings.push(`${colorPoints[k].x},${colorPoints[k].y},${colorPoints[k].hex}`); });
397
+ if (colorStrings.length < 3) {
398
+ window.parent.gp.info.error("取色数量不足3个", "请保证至少3个点位的取色 (推荐5个以上),以提高找色准确度!");
399
+ return;
400
+ }
401
+
402
+ const btn = $('#btn-test');
403
+ const content = $('#btn-content');
404
+ const resList = $('#res-list');
405
+ const resCount = $('#res-count');
406
+
407
+ // 1. 进入加载状态
408
+ btn.prop('disabled', true);
409
+ content.html('<span class="spinner-border spinner-border-sm me-2"></span>执行中...');
410
+
411
+ const startTime = Date.now();
412
+
413
+ try {
414
+ // 2. 调用找色接口获取二维数组结果
415
+ // 假设返回格式为: [[x1, y1], [x2, y2], ...]
416
+ resList.empty();
417
+ window.parent.gp.marks.clear()
418
+ const res = await genTest();
419
+ console.log("找色结果:", res);
420
+
421
+ // 3. 计算耗时,确保动画平滑(至少展示 300ms)
422
+ const elapsedTime = Date.now() - startTime;
423
+ const delay = Math.max(0, 200 - elapsedTime);
424
+
425
+ setTimeout(() => {
426
+ // 4. 清空旧结果并恢复按钮
427
+
428
+ btn.prop('disabled', false);
429
+ content.html('<i class="bi bi-play-fill me-1"></i> 执行测试找色');
430
+
431
+ // 5. 处理结果数组
432
+ if (res && res.length > 0) {
433
+ resCount.text(res.length); // 更新计数
434
+
435
+ // 遍历二维数组渲染条目
436
+ // 遍历二维数组渲染条目
437
+ res.forEach((point, index) => {
438
+ const x = point[0];
439
+ const y = point[1];
440
+ const mark_label = `#${index}`;
441
+
442
+ // 添加标记到地图
443
+ window.parent.gp.marks.add_point(mark_label, x, y);
444
+
445
+ // 生成更干净的列表项
446
+ const itemHtml = `
447
+ <div class="res-item"
448
+ onmouseenter="window.parent.gp.marks.high_light('${mark_label}')"
449
+ onmouseleave="window.parent.gp.marks.high_light_clear()">
450
+ <span class="label-tag me-2">${mark_label}</span>
451
+ <div class="flex-grow-1">
452
+ <span class="text-white-50 small">X:</span> <strong>${x}</strong>
453
+ <span class="text-white-50 small ms-2">Y:</span> <strong>${y}</strong>
454
+ </div>
455
+ <i class="bi bi-chevron-right opacity-25"></i>
456
+ </div>
457
+ `;
458
+ resList.append(itemHtml);
459
+ });
460
+ } else {
461
+ // 无结果显示
462
+ resCount.text('0');
463
+ resList.append('<div class="text-center opacity-25 mt-4 small">未找到匹配颜色</div>');
464
+ }
465
+ }, delay);
466
+
467
+ } catch (error) {
468
+ // 错误处理
469
+ console.error("测试运行失败:", error);
470
+ btn.prop('disabled', false);
471
+ content.html('<i class="bi bi-exclamation-triangle me-1"></i> 运行出错');
472
+ resList.html('<div class="text-center text-danger mt-4 small">接口调用异常</div>');
473
+ }
474
+ }
475
+
476
+ function genCode() {
477
+ const keys = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
478
+ let colorStrings = [];
479
+ keys.forEach(k => { if (colorPoints[k]) colorStrings.push(`${colorPoints[k].x},${colorPoints[k].y},${colorPoints[k].hex}`); });
480
+ if (colorStrings.length < 3) { $('#code-box').html("<span style='color:#6a9955'># 请至少取3个点的颜色...</span>"); return; }
481
+
482
+ let config = getConfigValues();
483
+ let rect_line = "";
484
+ let threshold = "";
485
+ let ori_line = config.ori == 2 ? "" : `, ori=${config.ori}`;
486
+ let exclusion_radius_line = config.exclusion_radius != 5 ? `, exclusion_radius=${config.exclusion_radius}` : "";
487
+ if (!config.isFullScreen) {
488
+ rect_line = `,rect=${config.rect}`;
489
+ }
490
+
491
+ if (config.threshold != 0.95) {
492
+ threshold = `,threshold=${config.threshold}`;
493
+ }
494
+
495
+ const pythonCode = `from ascript.windows.screen import FindColors
496
+ FindColors.${$('#check-multi').is(':checked') ? "find_all" : "find"}("${colorStrings.join('|')}"${rect_line}${threshold}${ori_line}${exclusion_radius_line})
497
+ `;
498
+ // const codeText = `from ascript.windows.screen import FindColors\n\nresults = FindColors.${$('#check-multi').is(':checked') ? "find_all" : "find"}(\n colors="${colorStrings.join('|')}",\n rect=${currentRect ? `[${currentRect.l}, ${currentRect.t}, ${currentRect.r}, ${currentRect.b}]` : "None"},\n threshold=${$('#threshold').val()},\n ori=${$('#select-ori').val()}\n)`;
499
+ $('#code-box').text(pythonCode);
500
+ }
501
+
502
+ async function genTest() {
503
+ const keys = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"];
504
+ let colorStrings = [];
505
+ keys.forEach(k => { if (colorPoints[k]) colorStrings.push(`${colorPoints[k].x},${colorPoints[k].y},${colorPoints[k].hex}`); });
506
+ if (colorStrings.length === 0) { $('#code-box').html("<span style='color:#6a9955'># 请先取色...</span>"); return; }
507
+
508
+ let config = getConfigValues();
509
+ let rect_line = "";
510
+ let threshold = "";
511
+ let ori_line = config.ori == 2 ? "" : `, ori=${config.ori}`;
512
+ let exclusion_radius_line = config.exclusion_radius != 5 ? `, exclusion_radius=${config.exclusion_radius}` : "";
513
+ let im_source_line = `, im_source=r"${window.parent.gp.image.path}"`;
514
+ let max_res_line = $('#check-multi').is(':checked') ? "" : ",max_res=1";
515
+ if (!config.isFullScreen) {
516
+ rect_line = `,rect=${config.rect}`;
517
+ }
518
+
519
+ if (config.threshold != 0.95) {
520
+ threshold = `,threshold=${config.threshold}`;
521
+ }
522
+
523
+ const pythonCode = `from ascript.windows.screen import FindColors
524
+ _result =FindColors.find_all("${colorStrings.join('|')}"${rect_line}${threshold}${ori_line}${im_source_line}${exclusion_radius_line}${max_res_line})`;
525
+ return await window.parent.gp.call_python(pythonCode);
526
+ }
527
+
528
+ function updateSlotUI(key) {
529
+ const d = colorPoints[key];
530
+ const row = $(`#row-${key}`);
531
+ if (d) {
532
+ row.addClass('active');
533
+ $(`#pre-${key}`).css('background', d.hex);
534
+ $(`#hex-${key}`).text(d.hex.toUpperCase());
535
+ $(`#pos-${key}`).text(`${d.x},${d.y}`);
536
+ } else {
537
+ row.removeClass('active');
538
+ $(`#pre-${key}`).css('background', 'transparent');
539
+ $(`#hex-${key}`).text('--');
540
+ $(`#pos-${key}`).text('--');
541
+ }
542
+ }
543
+
544
+ /**
545
+ * 获取当前界面的所有配置参数
546
+ * @returns {Object} 包含所有参数的对象
547
+ */
548
+ function getConfigValues() {
549
+ // 1. 判断是全屏还是范围
550
+ // 获取输入框的值
551
+ const rectValue = $('#input-rect').val().trim();
552
+
553
+ let finalRect = null;
554
+ if (rectValue && rectValue !== "" && rectValue !== "全屏模式") {
555
+ // 如果有值,说明用户选择了范围
556
+ // 假设 input-rect 的值格式是 "100,200,500,600"
557
+ // 转换成 Python 数组格式 [l, t, r, b]
558
+ finalRect = `[${rectValue}]`;
559
+ } else {
560
+ // 如果值为空,则是全屏模式
561
+ finalRect = "None";
562
+ }
563
+
564
+ // 2. 获取其他基础参数
565
+ const config = {
566
+ isFullScreen: finalRect === "None", // 布尔值判断:是否为全屏
567
+ rect: finalRect, // 字符串:用于生成代码的 rect 参数
568
+ threshold: parseFloat($('#threshold').val()) || 0.9, // 匹配阈值
569
+ exclusion_radius: parseInt($('#exclusion_radius').val()) || 5, // 排他间隔
570
+ ori: parseInt($('#select-ori').val()), // 找色方向
571
+ isMulti: $('#check-multi').is(':checked'), // 是否查找多个
572
+ };
573
+
574
+ return config;
575
+ }
576
+
577
+ window.on_color_picked = (d) => { colorPoints[d.key] = { x: d.pos[0], y: d.pos[1], hex: d.color }; updateSlotUI(d.key); genCode(); };
578
+ window.on_area_selected = (d) => { if (d && (d.l + d.r !== 0)) { currentRect = d; $('#input-rect').val(`${d.l},${d.t},${d.r},${d.b}`); } else { currentRect = null; $('#input-rect').val(''); } genCode(); };
579
+ function clearSlot(key) { delete colorPoints[key]; updateSlotUI(key); genCode(); }
580
+ function clearAllSlots() { colorPoints = {};["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"].forEach(updateSlotUI); genCode(); }
581
+ function clearRect() { currentRect = null; $('#input-rect').val(''); genCode(); }
582
+ function clearResults() {
583
+ $('#res-list').empty().append('<div class="text-center opacity-25 mt-4 small">已清空</div>'); $('#res-count').text('0');
584
+ window.parent.gp.marks.clear();
585
+ }
586
+ function copyCode() {
587
+ var code = $('#code-box').text()
588
+ navigator.clipboard.writeText(code);
589
+ const $btn = $("#copy_code");
590
+ $btn.html('<i class="bi bi-check text-success"></i> Copied');
591
+ setTimeout(() => $btn.html('<i class="bi bi-files me-1"></i>Copy'), 1500);
592
+ window.parent.gp.info.noti(`${code} 已复制到剪贴板`);
593
+ }
594
+
595
+ $(document).ready(() => {
596
+ initSlots(); genCode(); $('input, select, .form-check-input').on('change input', genCode);
597
+ window.parent.gp.iframe.on_rect();
598
+ });
599
+
600
+ // 在 iframe 内部的代码中添加
601
+ $(document).on('keydown', (e) => {
602
+ // --- 新增:判定是否正在输入 ---
603
+ const target = e.target;
604
+ const isInput = target.tagName === 'INPUT' ||
605
+ target.tagName === 'TEXTAREA' ||
606
+ target.isContentEditable;
607
+
608
+ // 如果正在输入,直接返回,不执行转发逻辑
609
+ if (isInput) return;
610
+
611
+ // --- 原有转发逻辑 ---
612
+ if (e.key >= '0' && e.key <= '9') {
613
+ if (window.parent && typeof window.parent.dispatchEvent === 'function') {
614
+ const clonedEvent = new KeyboardEvent('keydown', {
615
+ key: e.key,
616
+ code: e.code,
617
+ ctrlKey: e.ctrlKey, // 建议加上,确保 Ctrl+数字 也能正确识别
618
+ shiftKey: e.shiftKey,
619
+ altKey: e.altKey,
620
+ bubbles: true
621
+ });
622
+ window.parent.dispatchEvent(clonedEvent);
623
+ }
624
+ }
625
+ });
626
+ </script>
627
+ </body>
628
+
629
+ </html>