简体   繁体   English

在Python中使用Win32api创建新的屏幕缓冲区

[英]Create new screen buffer with win32api in Python

I want to draw a specific image to my second screen in Windows 7 using Python 3.4. 我想使用Python 3.4在Windows 7中的第二个屏幕上绘制特定的图像。 I can get the handle and screen dimensions using pywin32 : 我可以使用pywin32获得手柄和屏幕尺寸:

import win32api
screens = win32api.EnumDisplayMonitors()

I get the handles,dimensions of my screens: 我得到了屏幕的手柄,尺寸:

[(<PyHANDLE:393217>, <PyHANDLE:0>, (0, 0, 1280, 720)),
(<PyHANDLE:7472233>, <PyHANDLE:0>, (1920, 0, 3360, 900))]

I thought of creating a new buffer with the dimensions of my screen , writing my data/image to the new buffer and setting it as the active screen. 我想创建一个具有屏幕尺寸的新缓冲区,将数据/图像写入新缓冲区并将其设置为活动屏幕。

I don't think I can do that with the pywin32 module and I though of accessing the Windows API through ctypes. 我不认为我可以使用pywin32模块来做到这一点,尽管我可以通过ctypes访问Windows API。 But I cannot find the functions of the API like described here https://msdn.microsoft.com/en-us/library/windows/desktop/ms685032(v=vs.85).aspx 但是我找不到像这里描述的API的功能https://msdn.microsoft.com/zh-cn/library/windows/desktop/ms685032(v=vs.85).aspx

How can I do that? 我怎样才能做到这一点? Thank you! 谢谢!

Can use the win32console module: 可以使用win32console模块:

=> python
Python 3.4.3 |Anaconda 2.3.0 (64-bit)| (default, Mar  6 2015, 12:06:10) [MSC v.1600 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import win32console
>>> help(win32console.CreateConsoleScreenBuffer)
Help on built-in function CreateConsoleScreenBuffer in module win32console:

CreateConsoleScreenBuffer(...)
    Creates a new console screen buffer

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM