From 2ad08423ce2d6df14846d208103488d89c066e40 Mon Sep 17 00:00:00 2001 From: yv1ing Date: Fri, 28 Mar 2025 16:03:06 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A0=E5=85=A5Python=E8=B0=83=E7=94=A8DLL?= =?UTF-8?q?=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- gui/main.py | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 gui/main.py diff --git a/gui/main.py b/gui/main.py new file mode 100644 index 0000000..a743d0a --- /dev/null +++ b/gui/main.py @@ -0,0 +1,31 @@ +import ctypes + + +def shot(target, width, height): + lib = ctypes.CDLL('../shotrdp.dll') + + lib.GetScreen.argtypes = [ + ctypes.c_char_p, + ctypes.POINTER(ctypes.POINTER(ctypes.c_char)), + ctypes.POINTER(ctypes.c_int), + ctypes.c_int, + ctypes.c_int, + ] + lib.GetScreen.restype = ctypes.c_char_p + + data = ctypes.POINTER(ctypes.c_char)() + length = ctypes.c_int() + + error_ptr = lib.GetScreen(target, ctypes.byref(data), ctypes.byref(length), width, height) + if error_ptr: + print(ctypes.string_at(error_ptr).decode()) + else: + result = ctypes.string_at(data, length.value) + with open('test.png', 'wb') as f: + f.write(result) + + lib.Free(data) + + +if __name__ == '__main__': + shot(b'127.0.0.1:3389', 1024, 800) \ No newline at end of file