Get monitor serial number using PyQt

不问归期 提交于 2019-12-24 11:28:23

问题


I helping out on an FOSS application which uses PyQt 5. It is a dual screen application, and I would like to track the monitors that get connected, and persist settings if they get disconnected.

We're using QScreen for the info we need, and this is great, but on Windows and on Linux the 'serialNumber' property returns an empty string, as does the 'manufacturer' and 'model' properties.

import sys

from PyQt5 import QtGui
app = QtGui.QGuiApplication(sys.argv)

print(repr(app.screens()[0].serialNumber()))

Any suggestions on how I can obtain the serial number?

For Windows the snippet at https://www.activexperts.com/admin/scripts/wmiscripts/python/0073/ works, but I have found no way of relating this information to the X & Y position of the monitor:

来源:https://stackoverflow.com/questions/55182931/get-monitor-serial-number-using-pyqt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!