码迷,mamicode.com
首页 > 编程语言 > 详细

【转载】 Python 调整屏幕分辨率

时间:2015-04-09 10:22:07      阅读:222      评论:0      收藏:0      [点我收藏+]

标签:

转载来自: http://www.cnblogs.com/fatterbetter/p/4115423.html

 

需要用windows的api,ChangeDisplaySettings 

实现代码如下:

1 import win32api
2 dm = win32api.EnumDisplaySettings(None, 0)
3 dm.PelsHeight = 900
4 dm.PelsWidth = 1400
5 dm.BitsPerPel = 32
6 dm.DisplayFixedOutput = 0
7 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 调整屏幕分辨率

标签:

原文地址:http://www.cnblogs.com/dcb3688/p/4408764.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!