Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Decided to give up talking directly to the monitor and instead parsing EDID information cached in the registry. This code isn't perfect, but it works:</p> <pre><code>import win32api as api, win32con as con, pywintypes import win32com.client _objWMIService = win32com.client.Dispatch('WbemScripting.SWbemLocator') _objSWbemServices = _objWMIService.ConnectServer('.', 'root\\cimv2') wmiquery = _objSWbemServices.ExecQuery # get_regval(regkey) is simple registry reading function. def get_monitor_res(): dtd = 54 # start byte of detailed timing desc. try: # get PNP id to find EDID in registry for monitor in wmiquery('Select * from Win32_DesktopMonitor'): # http://msdn.microsoft.com/en-us/library/aa394122%28VS.85%29.aspx if monitor.Availability in (3, 7, 13, 14, 15, 16): # connected curres = (monitor.ScreenWidth, monitor.ScreenHeight) print 'DEBUG: Current monitor resolution from WMI: %s' % (curres,) regkey = ('HKLM\\SYSTEM\\CurrentControlSet\\Enum\\' + monitor.PNPDeviceID + '\\Device Parameters\\EDID') edid = get_regval(regkey) if edid: print 'DEBUG: EDID Version: %s.%s' % (edid[18], edid[19]) # upper nibble of byte x 2^8 combined with full byte hres = ((edid[dtd+4] &gt;&gt; 4) &lt;&lt; 8) | edid[dtd+2] vres = ((edid[dtd+7] &gt;&gt; 4) &lt;&lt; 8) | edid[dtd+5] print 'DEBUG: EDID DTD0: ' + str((hres, vres)) res = (hres, vres) break # give up on first success else: raise RuntimeError, 'EDID not found in registry' except (RuntimeError, Exception) as err: print 'ERROR: %s.' % err return res </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload