admin管理员组文章数量:1592245
"""
# 文件说明 :windows的一些函数
# @Time : 2022-3-26 14:23
# @Author : hewuhun
# @File : windows_common.py
# @Software : python
"""
# !/usr/bin/python
# -*- coding: utf-8 -*-
import win32api
import win32con
import win32gui
import win32print
class WindowsCommon:
"""
windows的一些函数
"""
def __init__(self):
self.hdc = win32gui.GetDC(0)
def getScreenResolution(self):
"""
得到屏幕的真实分辨率
:return:
"""
sx = win32print.GetDeviceCaps(self.hdc, win32con.DESKTOPHORZRES)
sy = win32print.GetDeviceCaps(self.hdc, win32con.DESKTOPVERTRES)
return sx, sy
@staticmethod
def getScreenCurrent():
"""
得到屏幕缩放后的分辨率
:return:
"""
sx = win32api.GetSystemMetrics(win32con.SM_CXSCREEN)
sy = win32api.GetSystemMetrics(win32con.SM_CYSCREEN)
return sx, sy
def getScreenScaleRate(self):
"""
得到当前屏幕的缩放比例
:return:
"""
screen_x, screen_y = self.getScreenResolution()
current_x, current_y = self.getScreenCurrent()
rate = round(screen_x / current_x, 2)
return rate
if __name__ == '__main__':
windows_common = WindowsCommon()
print(windows_common.getScreenScaleRate())
版权声明:本文标题:python得到windows系统显示的缩放倍数 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dongtai/1728135370a1146728.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论