How to? Identify which monitor is active

#1
When my laptop is docked, usually an external monitor capable of 1280x1024 resolution is used. The internal monitor is limited to 1024x768 resolution. The video system description string provided by SCREENRES is identical. I would like to be able to query the video system to determine what is the highest resolution available on the currently active monitor without changing resolution.
 
#2
When my laptop is docked, usually an external monitor capable of 1280x1024 resolution is used. The internal monitor is limited to 1024x768 resolution. The video system description string provided by SCREENRES is identical. I would like to be able to query the video system to determine what is the highest resolution available on the currently active monitor without changing resolution.
Maybe the SCREENRES command in the UIStuff plugin, (by Charles Dye), will do what you want. It can be downloaded from http://prospero.unm.edu/dl/uistuff.zip

On my two monitor system, the following command;

Code:
screenres /a/l
gives;

Code:
0  Generic PnP Monitor on NVIDIA GeForce 9300 GE:
    640 x  480 (32) at  60 Hz
    640 x  480 (32) at  75 Hz
    720 x  480 (32) at  60 Hz
    720 x  480 (32) at  60 Hz
    720 x  480 (32) at  60 Hz
    720 x  480 (32) at  75 Hz
    720 x  480 (32) at  75 Hz
    720 x  480 (32) at  75 Hz
    720 x  576 (32) at  60 Hz
    720 x  576 (32) at  60 Hz
    720 x  576 (32) at  60 Hz
    720 x  576 (32) at  75 Hz
    720 x  576 (32) at  75 Hz
    720 x  576 (32) at  75 Hz
    800 x  600 (32) at  60 Hz
    800 x  600 (32) at  75 Hz
  1024 x  768 (32) at  60 Hz
  1024 x  768 (32) at  75 Hz
  1152 x  864 (32) at  75 Hz
  1280 x  720 (32) at  60 Hz
  1280 x  720 (32) at  60 Hz
  1280 x  720 (32) at  60 Hz
  1280 x  720 (32) at  75 Hz
  1280 x  720 (32) at  75 Hz
  1280 x  720 (32) at  75 Hz
  1280 x  768 (32) at  60 Hz
  1280 x  768 (32) at  60 Hz
  1280 x  768 (32) at  60 Hz
  1280 x  768 (32) at  75 Hz
  1280 x  768 (32) at  75 Hz
  1280 x  768 (32) at  75 Hz
  1280 x  800 (32) at  60 Hz
  1280 x  800 (32) at  60 Hz
  1280 x  800 (32) at  60 Hz
  1280 x  800 (32) at  75 Hz
  1280 x  800 (32) at  75 Hz
  1280 x  800 (32) at  75 Hz
  1280 x  960 (32) at  60 Hz
  1280 x  960 (32) at  60 Hz
  1280 x  960 (32) at  60 Hz
  1280 x  960 (32) at  75 Hz
  1280 x  960 (32) at  75 Hz
  1280 x  960 (32) at  75 Hz
  1280 x 1024 (32) at  60 Hz
  1280 x 1024 (32) at  75 Hz
  1360 x  768 (32) at  59 Hz
  1360 x  768 (32) at  60 Hz
  1360 x  768 (32) at  59 Hz
  1360 x  768 (32) at  60 Hz
  1360 x  768 (32) at  59 Hz
  1360 x  768 (32) at  60 Hz
  1600 x  900 (32) at  59 Hz
  1600 x  900 (32) at  60 Hz
  1600 x  900 (32) at  59 Hz
  1600 x  900 (32) at  60 Hz
  1600 x  900 (32) at  59 Hz
  1600 x  900 (32) at  60 Hz
  1600 x 1024 (32) at  59 Hz
  1600 x 1024 (32) at  60 Hz
  1600 x 1024 (32) at  59 Hz
  1600 x 1024 (32) at  60 Hz
  1600 x 1024 (32) at  59 Hz
  1600 x 1024 (32) at  60 Hz
  1680 x 1050 (32) at  59 Hz
  1680 x 1050 (32) at  60 Hz
  1920 x 1080 (32) at  60 Hz
    640 x  480 (16) at  60 Hz
    640 x  480 (16) at  75 Hz
    720 x  480 (16) at  60 Hz
    720 x  480 (16) at  60 Hz
    720 x  480 (16) at  60 Hz
    720 x  480 (16) at  75 Hz
    720 x  480 (16) at  75 Hz
    720 x  480 (16) at  75 Hz
    720 x  576 (16) at  60 Hz
    720 x  576 (16) at  60 Hz
    720 x  576 (16) at  60 Hz
    720 x  576 (16) at  75 Hz
    720 x  576 (16) at  75 Hz
    720 x  576 (16) at  75 Hz
    800 x  600 (16) at  60 Hz
    800 x  600 (16) at  75 Hz
  1024 x  768 (16) at  60 Hz
  1024 x  768 (16) at  75 Hz
  1152 x  864 (16) at  75 Hz
  1280 x  720 (16) at  60 Hz
  1280 x  720 (16) at  60 Hz
  1280 x  720 (16) at  60 Hz
  1280 x  720 (16) at  75 Hz
  1280 x  720 (16) at  75 Hz
  1280 x  720 (16) at  75 Hz
  1280 x  768 (16) at  60 Hz
  1280 x  768 (16) at  60 Hz
  1280 x  768 (16) at  60 Hz
  1280 x  768 (16) at  75 Hz
  1280 x  768 (16) at  75 Hz
  1280 x  768 (16) at  75 Hz
  1280 x  800 (16) at  60 Hz
  1280 x  800 (16) at  60 Hz
  1280 x  800 (16) at  60 Hz
  1280 x  800 (16) at  75 Hz
  1280 x  800 (16) at  75 Hz
  1280 x  800 (16) at  75 Hz
  1280 x  960 (16) at  60 Hz
  1280 x  960 (16) at  60 Hz
  1280 x  960 (16) at  60 Hz
  1280 x  960 (16) at  75 Hz
  1280 x  960 (16) at  75 Hz
  1280 x  960 (16) at  75 Hz
  1280 x 1024 (16) at  60 Hz
  1280 x 1024 (16) at  75 Hz
  1360 x  768 (16) at  59 Hz
  1360 x  768 (16) at  60 Hz
  1360 x  768 (16) at  59 Hz
  1360 x  768 (16) at  60 Hz
  1360 x  768 (16) at  59 Hz
  1360 x  768 (16) at  60 Hz
  1600 x  900 (16) at  59 Hz
  1600 x  900 (16) at  60 Hz
  1600 x  900 (16) at  59 Hz
  1600 x  900 (16) at  60 Hz
  1600 x  900 (16) at  59 Hz
  1600 x  900 (16) at  60 Hz
  1600 x 1024 (16) at  59 Hz
  1600 x 1024 (16) at  60 Hz
  1600 x 1024 (16) at  59 Hz
  1600 x 1024 (16) at  60 Hz
  1600 x 1024 (16) at  59 Hz
  1600 x 1024 (16) at  60 Hz
  1680 x 1050 (16) at  59 Hz
  1680 x 1050 (16) at  60 Hz
  1920 x 1080 (16) at  60 Hz
    640 x  480 ( 8) at  60 Hz
    640 x  480 ( 8) at  75 Hz
    720 x  480 ( 8) at  60 Hz
    720 x  480 ( 8) at  60 Hz
    720 x  480 ( 8) at  60 Hz
    720 x  480 ( 8) at  75 Hz
    720 x  480 ( 8) at  75 Hz
    720 x  480 ( 8) at  75 Hz
    720 x  576 ( 8) at  60 Hz
    720 x  576 ( 8) at  60 Hz
    720 x  576 ( 8) at  60 Hz
    720 x  576 ( 8) at  75 Hz
    720 x  576 ( 8) at  75 Hz
    720 x  576 ( 8) at  75 Hz
    800 x  600 ( 8) at  60 Hz
    800 x  600 ( 8) at  75 Hz
  1024 x  768 ( 8) at  60 Hz
  1024 x  768 ( 8) at  75 Hz
  1152 x  864 ( 8) at  75 Hz
  1280 x  720 ( 8) at  60 Hz
  1280 x  720 ( 8) at  60 Hz
  1280 x  720 ( 8) at  60 Hz
  1280 x  720 ( 8) at  75 Hz
  1280 x  720 ( 8) at  75 Hz
  1280 x  720 ( 8) at  75 Hz
  1280 x  768 ( 8) at  60 Hz
  1280 x  768 ( 8) at  60 Hz
  1280 x  768 ( 8) at  60 Hz
  1280 x  768 ( 8) at  75 Hz
  1280 x  768 ( 8) at  75 Hz
  1280 x  768 ( 8) at  75 Hz
  1280 x  800 ( 8) at  60 Hz
  1280 x  800 ( 8) at  60 Hz
  1280 x  800 ( 8) at  60 Hz
  1280 x  800 ( 8) at  75 Hz
  1280 x  800 ( 8) at  75 Hz
  1280 x  800 ( 8) at  75 Hz
  1280 x  960 ( 8) at  60 Hz
  1280 x  960 ( 8) at  60 Hz
  1280 x  960 ( 8) at  60 Hz
  1280 x  960 ( 8) at  75 Hz
  1280 x  960 ( 8) at  75 Hz
  1280 x  960 ( 8) at  75 Hz
  1280 x 1024 ( 8) at  60 Hz
  1280 x 1024 ( 8) at  75 Hz
  1360 x  768 ( 8) at  59 Hz
  1360 x  768 ( 8) at  60 Hz
  1360 x  768 ( 8) at  59 Hz
  1360 x  768 ( 8) at  60 Hz
  1360 x  768 ( 8) at  59 Hz
  1360 x  768 ( 8) at  60 Hz
  1600 x  900 ( 8) at  59 Hz
  1600 x  900 ( 8) at  60 Hz
  1600 x  900 ( 8) at  59 Hz
  1600 x  900 ( 8) at  60 Hz
  1600 x  900 ( 8) at  59 Hz
  1600 x  900 ( 8) at  60 Hz
  1600 x 1024 ( 8) at  59 Hz
  1600 x 1024 ( 8) at  60 Hz
  1600 x 1024 ( 8) at  59 Hz
  1600 x 1024 ( 8) at  60 Hz
  1600 x 1024 ( 8) at  59 Hz
  1600 x 1024 ( 8) at  60 Hz
  1680 x 1050 ( 8) at  59 Hz
  1680 x 1050 ( 8) at  60 Hz
  1920 x 1080 ( 8) at  60 Hz
  1440 x  900 ( 8) at  59 Hz
  1440 x  900 ( 8) at  60 Hz
  1440 x  900 ( 8) at  59 Hz
  1440 x  900 ( 8) at  60 Hz
  1440 x  900 ( 8) at  59 Hz
  1440 x  900 ( 8) at  60 Hz
  1152 x  720 ( 8) at  75 Hz
  1152 x  720 ( 8) at  75 Hz
  1152 x  720 ( 8) at  75 Hz
  1440 x  900 (16) at  59 Hz
  1440 x  900 (16) at  60 Hz
  1440 x  900 (16) at  59 Hz
  1440 x  900 (16) at  60 Hz
  1440 x  900 (16) at  59 Hz
  1440 x  900 (16) at  60 Hz
  1152 x  720 (16) at  75 Hz
  1152 x  720 (16) at  75 Hz
  1152 x  720 (16) at  75 Hz
  1440 x  900 (32) at  59 Hz
  1440 x  900 (32) at  60 Hz
  1440 x  900 (32) at  59 Hz
  1440 x  900 (32) at  60 Hz
  1440 x  900 (32) at  59 Hz
  1440 x  900 (32) at  60 Hz
  1152 x  720 (32) at  75 Hz
  1152 x  720 (32) at  75 Hz
  1152 x  720 (32) at  75 Hz
 
1* Generic PnP Monitor on NVIDIA GeForce 9300 GE:
  1440 x  900 ( 8) at  60 Hz
  1440 x  900 ( 8) at  75 Hz
  1440 x  900 (16) at  60 Hz
  1440 x  900 (16) at  75 Hz
  1440 x  900 (32) at  60 Hz
  1440 x  900 (32) at  75 Hz
    640 x  480 (32) at  60 Hz
    640 x  480 (32) at  75 Hz
    720 x  480 (32) at  60 Hz
    720 x  480 (32) at  60 Hz
    720 x  480 (32) at  60 Hz
    720 x  480 (32) at  75 Hz
    720 x  480 (32) at  75 Hz
    720 x  480 (32) at  75 Hz
    720 x  576 (32) at  60 Hz
    720 x  576 (32) at  60 Hz
    720 x  576 (32) at  60 Hz
    720 x  576 (32) at  75 Hz
    720 x  576 (32) at  75 Hz
    720 x  576 (32) at  75 Hz
    800 x  600 (32) at  60 Hz
    800 x  600 (32) at  75 Hz
  1024 x  768 (32) at  60 Hz
  1024 x  768 (32) at  75 Hz
  1152 x  864 (32) at  60 Hz
  1152 x  864 (32) at  60 Hz
  1152 x  864 (32) at  60 Hz
  1152 x  864 (32) at  75 Hz
  1152 x  864 (32) at  75 Hz
  1152 x  864 (32) at  75 Hz
  1280 x  720 (32) at  60 Hz
  1280 x  720 (32) at  60 Hz
  1280 x  720 (32) at  60 Hz
  1280 x  768 (32) at  60 Hz
  1280 x  768 (32) at  60 Hz
  1280 x  768 (32) at  60 Hz
  1280 x  800 (32) at  60 Hz
  1280 x  960 (32) at  60 Hz
  1280 x 1024 (32) at  60 Hz
  1280 x 1024 (32) at  75 Hz
  1360 x  768 (32) at  60 Hz
  1360 x  768 (32) at  60 Hz
  1360 x  768 (32) at  60 Hz
  1360 x  768 (32) at  75 Hz
  1360 x  768 (32) at  75 Hz
  1360 x  768 (32) at  75 Hz
    640 x  480 (16) at  60 Hz
    640 x  480 (16) at  75 Hz
    720 x  480 (16) at  60 Hz
    720 x  480 (16) at  60 Hz
    720 x  480 (16) at  60 Hz
    720 x  480 (16) at  75 Hz
    720 x  480 (16) at  75 Hz
    720 x  480 (16) at  75 Hz
    720 x  576 (16) at  60 Hz
    720 x  576 (16) at  60 Hz
    720 x  576 (16) at  60 Hz
    720 x  576 (16) at  75 Hz
    720 x  576 (16) at  75 Hz
    720 x  576 (16) at  75 Hz
    800 x  600 (16) at  60 Hz
    800 x  600 (16) at  75 Hz
  1024 x  768 (16) at  60 Hz
  1024 x  768 (16) at  75 Hz
  1152 x  864 (16) at  60 Hz
  1152 x  864 (16) at  60 Hz
  1152 x  864 (16) at  60 Hz
  1152 x  864 (16) at  75 Hz
  1152 x  864 (16) at  75 Hz
  1152 x  864 (16) at  75 Hz
  1280 x  720 (16) at  60 Hz
  1280 x  720 (16) at  60 Hz
  1280 x  720 (16) at  60 Hz
  1280 x  768 (16) at  60 Hz
  1280 x  768 (16) at  60 Hz
  1280 x  768 (16) at  60 Hz
  1280 x  800 (16) at  60 Hz
  1280 x  960 (16) at  60 Hz
  1280 x 1024 (16) at  60 Hz
  1280 x 1024 (16) at  75 Hz
  1360 x  768 (16) at  60 Hz
  1360 x  768 (16) at  60 Hz
  1360 x  768 (16) at  60 Hz
  1360 x  768 (16) at  75 Hz
  1360 x  768 (16) at  75 Hz
  1360 x  768 (16) at  75 Hz
    640 x  480 ( 8) at  60 Hz
    640 x  480 ( 8) at  75 Hz
    720 x  480 ( 8) at  60 Hz
    720 x  480 ( 8) at  60 Hz
    720 x  480 ( 8) at  60 Hz
    720 x  480 ( 8) at  75 Hz
    720 x  480 ( 8) at  75 Hz
    720 x  480 ( 8) at  75 Hz
    720 x  576 ( 8) at  60 Hz
    720 x  576 ( 8) at  60 Hz
    720 x  576 ( 8) at  60 Hz
    720 x  576 ( 8) at  75 Hz
    720 x  576 ( 8) at  75 Hz
    720 x  576 ( 8) at  75 Hz
    800 x  600 ( 8) at  60 Hz
    800 x  600 ( 8) at  75 Hz
  1024 x  768 ( 8) at  60 Hz
  1024 x  768 ( 8) at  75 Hz
  1152 x  864 ( 8) at  60 Hz
  1152 x  864 ( 8) at  60 Hz
  1152 x  864 ( 8) at  60 Hz
  1152 x  864 ( 8) at  75 Hz
  1152 x  864 ( 8) at  75 Hz
  1152 x  864 ( 8) at  75 Hz
  1280 x  720 ( 8) at  60 Hz
  1280 x  720 ( 8) at  60 Hz
  1280 x  720 ( 8) at  60 Hz
  1280 x  768 ( 8) at  60 Hz
  1280 x  768 ( 8) at  60 Hz
  1280 x  768 ( 8) at  60 Hz
  1280 x  800 ( 8) at  60 Hz
  1280 x  960 ( 8) at  60 Hz
  1280 x 1024 ( 8) at  60 Hz
  1280 x 1024 ( 8) at  75 Hz
  1360 x  768 ( 8) at  60 Hz
  1360 x  768 ( 8) at  60 Hz
  1360 x  768 ( 8) at  60 Hz
  1360 x  768 ( 8) at  75 Hz
  1360 x  768 ( 8) at  75 Hz
  1360 x  768 ( 8) at  75 Hz
  1152 x  720 ( 8) at  60 Hz
  1152 x  720 (16) at  60 Hz
  1152 x  720 (32) at  60 Hz
Joe
 
#3
Joe, I already use SCREENRES, and when my laptop is docked and closed, the external monitor shows up as monitor 0; when undocked the internal one is 0. If @WMI or another API can tell whether or not my computer is docked, it would be sufficient information for my purposes.
 

Charles Dye

Super Moderator
Staff member
May 20, 2008
3,619
46
Albuquerque, NM
prospero.unm.edu
#4
Joe, I already use SCREENRES, and when my laptop is docked and closed, the external monitor shows up as monitor 0; when undocked the internal one is 0. If @WMI or another API can tell whether or not my computer is docked, it would be sufficient information for my purposes.
%_HWPROFILE might reflect this, or %_MONITORS.
 
#5
Sorry, my bad.

When I issue the following on my Vista system;

Code:
wmiquery /a root\wmi "select * from WMIMonitorID"
it returns;

Code:
Active = True
InstanceName = DISPLAY\BNQ7805\5&3464a9ea&0&UID1048832_0
ManufacturerName = {66,78,81,0,0,0,0,0,0,0,0,0,0,0,0,0}
ProductCodeID = {55,56,48,53,0,0,0,0,0,0,0,0,0,0,0,0}
SerialNumberID = {56,65,55,48,56,49,57,54,83,76,48,0,0,0,0,0}
UserFriendlyName = {0}
UserFriendlyNameLength = 1
WeekOfManufacture = 42
YearOfManufacture = 2007
Active = True
InstanceName = DISPLAY\GSM56FE\5&3464a9ea&0&UID1048833_0
ManufacturerName = {71,83,77,0,0,0,0,0,0,0,0,0,0,0,0,0}
ProductCodeID = {53,54,70,69,0,0,0,0,0,0,0,0,0,0,0,0}
SerialNumberID = {54,51,53,56,51,0,0,0,0,0,0,0,0,0,0,0}
UserFriendlyName = {87,50,50,52,51,0}
UserFriendlyNameLength = 6
WeekOfManufacture = 5
YearOfManufacture = 2010
When I issue;

Code:
wmiquery /a root\cimv2 "select * from win32_desktopmonitor"
it returns;

Code:
Availability = 3
Caption = Generic PnP Monitor
ConfigManagerErrorCode = 0
ConfigManagerUserConfig = False
CreationClassName = Win32_DesktopMonitor
Description = Generic PnP Monitor
DeviceID = DesktopMonitor1
MonitorManufacturer = (Standard monitor types)
MonitorType = Generic PnP Monitor
Name = Generic PnP Monitor
PixelsPerXLogicalInch = 96
PixelsPerYLogicalInch = 96
PNPDeviceID = DISPLAY\BNQ7805\5&3464A9EA&0&UID1048832
ScreenHeight = 1080
ScreenWidth = 1920
Status = OK
SystemCreationClassName = Win32_ComputerSystem
SystemName = OPTIPLEX9601
I will do some more testing to see if I can get the resolutions of both monitors, not just the one, along with the highest resolution that they support.

I think that %@winmetrics will allow one to determine the size of each monitor, but not the maximum size.

Joe
 
#6
If @WMI or another API can tell whether or not my computer is docked, it would be sufficient information for my purposes.
I created _ISCOMPUTERDOCKED and put it in a plugin, which can be downloaded from http://www3.sympatico.ca/jcaverly/jlc2013.zip

As I have no means to test this, I would appreciate it if you would test it, and see if it works.

Here is the PowerBASIC code for the function in the plugin;

Code:
FUNCTION IsComputerDocked ALIAS "_ISCOMPUTERDOCKED" (BYVAL pstrArgs AS WORD PTR) EXPORT AS DWORD
  DIM hpi AS HW_PROFILE_INFO
  DIM Arguments AS STRING
  Arguments = ACodeZ(pstrArgs)
 
  CALL GetCurrentHwProfile(hpi)
  Arguments = LTRIM$(RTRIM$(STR$((hpi.dwDockInfo AND DOCKINFO_DOCKED))))
 
  Arguments = UCODE$(Arguments) + CHR$(0,0)
  CALL MoveMemory(BYVAL pstrArgs, BYVAL STRPTR(Arguments), LEN(Arguments))
  FUNCTION = 0
 
END FUNCTION
Joe