首页 > 编程语言 > 详细

python调win32api调整屏幕分辨率

时间:2014-11-22 18:41:39      阅读:1327      评论:0      收藏:0      [点我收藏+]

需要频繁切换屏幕分辨率,想写个脚本来实现,需要切换时运行一下就好

在网上查到,需要用windows的api,ChangeDisplaySettings 

实现代码如下

import win32api
dm = win32api.EnumDisplaySettings(None, 0)
dm.PelsHeight = 720
dm.PelsWidth = 1280
dm.BitsPerPel = 32
dm.DisplayFixedOutput = 0
win32api.ChangeDisplaySettings(dm, 0)

其中,一开始没有设置DisplayFixedOutput的值,在我机器上的效果是,切到小分辨率时,屏幕只在中间一小块,而在系统中调整时,是可以拉伸的,后来才找到是这个值在起作用

MSDN上的解释为

ValueMeaning 
DMDFO_DEFAULT The display‘s default setting. #define DMDFO_DEFAULT   0
DMDFO_CENTER The low-resolution image is centered in the larger screen space. #define DMDFO_CENTER    2
DMDFO_STRETCH The low-resolution image is stretched to fill the larger screen space.  #define DMDFO_STRETCH   1

将值设为1,或者0,在我机器上都为拉伸

有了这个脚本,需要改变分辨率时,只需双击一下

 

python调win32api调整屏幕分辨率

原文:http://www.cnblogs.com/fatterbetter/p/4115423.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!