wgc-python 2.0.1__py3-none-any.whl → 2.1.0__py3-none-any.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.
- wgc_python/__init__.py +62 -1
- wgc_python/wgc_python.dll +0 -0
- {wgc_python-2.0.1.dist-info → wgc_python-2.1.0.dist-info}/METADATA +18 -2
- wgc_python-2.1.0.dist-info/RECORD +7 -0
- {wgc_python-2.0.1.dist-info → wgc_python-2.1.0.dist-info}/WHEEL +1 -1
- wgc_python-2.0.1.dist-info/RECORD +0 -7
- {wgc_python-2.0.1.dist-info → wgc_python-2.1.0.dist-info/licenses}/LICENSE +0 -0
- {wgc_python-2.0.1.dist-info → wgc_python-2.1.0.dist-info}/top_level.txt +0 -0
wgc_python/__init__.py
CHANGED
|
@@ -157,4 +157,65 @@ class WindowCapture:
|
|
|
157
157
|
def handle(self) -> int: return self._h
|
|
158
158
|
|
|
159
159
|
|
|
160
|
-
|
|
160
|
+
class WindowCaptureMonitor:
|
|
161
|
+
"""显示器捕获类 - 捕获目标窗口所在显示器的全部内容
|
|
162
|
+
|
|
163
|
+
捕获会话绑定显示器而非窗口:目标窗口全屏/窗口切换不会使会话失效
|
|
164
|
+
(窗口捕获模式会在此时冻结于最后一帧)。仅捕获屏幕内容,无客户区裁剪。
|
|
165
|
+
|
|
166
|
+
Args:
|
|
167
|
+
title: 目标窗口标题(用于定位其所在显示器)
|
|
168
|
+
class_name: 目标窗口类名
|
|
169
|
+
"""
|
|
170
|
+
|
|
171
|
+
def __init__(self, title: str, class_name: str):
|
|
172
|
+
self._h = _dll.StartCaptureMonitorOfWindow(title.encode(), class_name.encode())
|
|
173
|
+
if not self._h:
|
|
174
|
+
raise RuntimeError(get_last_error())
|
|
175
|
+
|
|
176
|
+
def __del__(self): self.close()
|
|
177
|
+
def __enter__(self): return self
|
|
178
|
+
def __exit__(self, *_): self.close()
|
|
179
|
+
|
|
180
|
+
def get_frame(self) -> Optional[Tuple[int, int, int, int]]:
|
|
181
|
+
"""返回 (data_ptr, w, h, row_pitch) — 零拷贝 GPU 映射内存。
|
|
182
|
+
|
|
183
|
+
用完必须调用 release_frame(),期间不要再次调用。"""
|
|
184
|
+
if not self._h: return None
|
|
185
|
+
data = ctypes.POINTER(ctypes.c_ubyte)()
|
|
186
|
+
w, h, rp = ctypes.c_int(), ctypes.c_int(), ctypes.c_int()
|
|
187
|
+
if _dll.GetFrameMapped(self._h, ctypes.byref(data), ctypes.byref(w), ctypes.byref(h), ctypes.byref(rp)) == 0:
|
|
188
|
+
return None
|
|
189
|
+
return (ctypes.cast(data, ctypes.c_void_p).value, w.value, h.value, rp.value)
|
|
190
|
+
|
|
191
|
+
def release_frame(self):
|
|
192
|
+
if self._h: _dll.ReleaseMappedFrame(self._h)
|
|
193
|
+
|
|
194
|
+
def stop(self):
|
|
195
|
+
if self._h: _dll.StopCapture(self._h)
|
|
196
|
+
|
|
197
|
+
def pause(self):
|
|
198
|
+
if self._h: _dll.PauseCapture(self._h)
|
|
199
|
+
|
|
200
|
+
def resume(self):
|
|
201
|
+
if self._h: _dll.ResumeCapture(self._h)
|
|
202
|
+
|
|
203
|
+
def is_capturing(self) -> bool:
|
|
204
|
+
return bool(self._h and _dll.IsCapturing(self._h))
|
|
205
|
+
|
|
206
|
+
def is_paused(self) -> bool:
|
|
207
|
+
return bool(self._h and _dll.IsPaused(self._h))
|
|
208
|
+
|
|
209
|
+
def get_frame_count(self) -> int:
|
|
210
|
+
return _dll.GetFrameCount(self._h) if self._h else 0
|
|
211
|
+
|
|
212
|
+
def close(self):
|
|
213
|
+
if self._h:
|
|
214
|
+
_dll.DestroyCapture(self._h)
|
|
215
|
+
self._h = 0
|
|
216
|
+
|
|
217
|
+
@property
|
|
218
|
+
def handle(self) -> int: return self._h
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
__all__ = ['WindowCapture', 'WindowCaptureMonitor', 'enumerate_windows', 'get_last_error', 'get_active_capture_count']
|
wgc_python/wgc_python.dll
CHANGED
|
Binary file
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
Metadata-Version: 2.
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
2
|
Name: wgc_python
|
|
3
|
-
Version: 2.0
|
|
3
|
+
Version: 2.1.0
|
|
4
4
|
Summary: Windows Graphics Capture 窗口捕获库 — BGRA numpy 帧、按需捕获、零拷贝 GPU 路径
|
|
5
5
|
Author: XuanChenxuan
|
|
6
6
|
License: MIT
|
|
@@ -26,6 +26,7 @@ Description-Content-Type: text/markdown
|
|
|
26
26
|
License-File: LICENSE
|
|
27
27
|
Requires-Dist: numpy
|
|
28
28
|
Requires-Dist: opencv-python
|
|
29
|
+
Dynamic: license-file
|
|
29
30
|
|
|
30
31
|
# wgc_python
|
|
31
32
|
|
|
@@ -174,6 +175,21 @@ while True:
|
|
|
174
175
|
cap.close()
|
|
175
176
|
```
|
|
176
177
|
|
|
178
|
+
### 显示器捕获(推荐全屏游戏场景使用)
|
|
179
|
+
|
|
180
|
+
捕获目标窗口**所在的显示器**而非窗口本身:捕获会话绑定显示器,**目标窗口在全屏/窗口之间切换不会使捕获会话失效**(窗口捕获模式下此场景会冻结于最后一帧)。
|
|
181
|
+
|
|
182
|
+
```python
|
|
183
|
+
from wgc_python import WindowCaptureMonitor
|
|
184
|
+
|
|
185
|
+
# 定位目标窗口所在的显示器并捕获其全部内容(无客户区裁剪)
|
|
186
|
+
cap = WindowCaptureMonitor("游戏窗口", "UnityWndClass")
|
|
187
|
+
frame = cap.capture_one() # 整屏 BGRA 帧
|
|
188
|
+
cap.close()
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
适用场景:全屏游戏的长期自动化采集、目标窗口显示模式频繁变化的场景。需要裁剪客户区或排除其他窗口内容时,仍请使用 `WindowCapture`。
|
|
192
|
+
|
|
177
193
|
### 零拷贝高级用法
|
|
178
194
|
|
|
179
195
|
```python
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
wgc_python/__init__.py,sha256=rpzrOz1oaluBuK7Qg3g3E2kE45_80Ff03xjahRe1b8E,8429
|
|
2
|
+
wgc_python/wgc_python.dll,sha256=0T1liFK7PJShi5pT1Ym06gURBNIXgNxWnQOKMIiSao8,348160
|
|
3
|
+
wgc_python-2.1.0.dist-info/licenses/LICENSE,sha256=B5ek2R7a_iool-DvWfPuU-DlXlL-Meo1HBpDXfnqi2Y,1090
|
|
4
|
+
wgc_python-2.1.0.dist-info/METADATA,sha256=OKHyScy-Pf3i9pTyECNRA04nH6Yf2BNCNFegmpDonkE,27656
|
|
5
|
+
wgc_python-2.1.0.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
6
|
+
wgc_python-2.1.0.dist-info/top_level.txt,sha256=xqnLXhvRXiyjxTPKMDQSQSwa3NfcRhOAnLXj3YCpNp0,11
|
|
7
|
+
wgc_python-2.1.0.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
wgc_python/__init__.py,sha256=TyGhYB64Hvs1cK666ScerI1Vtv8erZDUg5C6I_aruHI,6248
|
|
2
|
-
wgc_python/wgc_python.dll,sha256=Y-pJOFlmAN8NysLQGO8aLBAIEp1Ty_s311wffZiJaMM,340992
|
|
3
|
-
wgc_python-2.0.1.dist-info/LICENSE,sha256=B5ek2R7a_iool-DvWfPuU-DlXlL-Meo1HBpDXfnqi2Y,1090
|
|
4
|
-
wgc_python-2.0.1.dist-info/METADATA,sha256=TXtdivxqwqD-QO8uwcKbSIGbVxpMhhl0WTfRp797pek,26880
|
|
5
|
-
wgc_python-2.0.1.dist-info/WHEEL,sha256=R0nc6qTxuoLk7ShA2_Y-UWkN8ZdfDBG2B6Eqpz2WXbs,91
|
|
6
|
-
wgc_python-2.0.1.dist-info/top_level.txt,sha256=xqnLXhvRXiyjxTPKMDQSQSwa3NfcRhOAnLXj3YCpNp0,11
|
|
7
|
-
wgc_python-2.0.1.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|