graphics() improving display detection (windows)
This commit is contained in:
parent
7cbb8ac52f
commit
8acd0ece14
@ -561,6 +561,7 @@ function graphics(callback) {
|
|||||||
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
|
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams | fl'));
|
||||||
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
|
workload.push(util.powerShell('Add-Type -AssemblyName System.Windows.Forms; [System.Windows.Forms.Screen]::AllScreens'));
|
||||||
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
|
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
|
||||||
|
workload.push(util.powerShell('gwmi WmiMonitorID -Namespace root\\wmi | ForEach-Object {(($_.ManufacturerName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.ProductCodeID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.UserFriendlyName -notmatch 0 | foreach {[char]$_}) -join "") + "|" + (($_.SerialNumberID -notmatch 0 | foreach {[char]$_}) -join "") + "|" + $_.InstanceName}'));
|
||||||
|
|
||||||
Promise.all(
|
Promise.all(
|
||||||
workload
|
workload
|
||||||
@ -587,19 +588,34 @@ function graphics(callback) {
|
|||||||
let tsections = data[4].split(/\n\s*\n/);
|
let tsections = data[4].split(/\n\s*\n/);
|
||||||
tsections.shift();
|
tsections.shift();
|
||||||
|
|
||||||
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections);
|
// monitor ID (powershell) - model / vendor
|
||||||
|
const res = data[5].split(/\r/);
|
||||||
|
let isections = [];
|
||||||
|
res.forEach(element => {
|
||||||
|
const parts = element.split('|');
|
||||||
|
if (parts.length === 5) {
|
||||||
|
isections.push({
|
||||||
|
vendor: parts[0],
|
||||||
|
code: parts[1],
|
||||||
|
model: parts[2],
|
||||||
|
serial: parts[3],
|
||||||
|
instanceId: parts[4]
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections);
|
||||||
|
|
||||||
if (result.controllers.length === 1 && result.displays.length === 1) {
|
if (result.controllers.length === 1 && result.displays.length === 1) {
|
||||||
if (_resolutionx) {
|
if (_resolutionx) {
|
||||||
result.displays[0].currentResX = _resolutionx;
|
result.displays[0].resolutionx = _resolutionx;
|
||||||
if (!result.displays[0].resolutionx) {
|
if (!result.displays[0].currentResX) {
|
||||||
result.displays[0].resolutionx = _resolutionx;
|
result.displays[0].currentResX = _resolutionx;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_resolutiony) {
|
if (_resolutiony) {
|
||||||
result.displays[0].currentResY = _resolutiony;
|
result.displays[0].resolutiony = _resolutiony;
|
||||||
if (result.displays[0].resolutiony === 0) {
|
if (result.displays[0].currentResY === 0) {
|
||||||
result.displays[0].resolutiony = _resolutiony;
|
result.displays[0].currentResY = _resolutiony;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (_pixeldepth) {
|
if (_pixeldepth) {
|
||||||
@ -677,7 +693,7 @@ function graphics(callback) {
|
|||||||
// return displays;
|
// return displays;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections) {
|
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections, isections) {
|
||||||
let displays = [];
|
let displays = [];
|
||||||
let vendor = '';
|
let vendor = '';
|
||||||
let model = '';
|
let model = '';
|
||||||
@ -706,9 +722,17 @@ function graphics(callback) {
|
|||||||
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
|
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
|
||||||
const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase();
|
const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase();
|
||||||
const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology');
|
const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology');
|
||||||
|
let displayVendor = '';
|
||||||
|
let displayModel = '';
|
||||||
|
isections.forEach(element => {
|
||||||
|
if (element.instanceId.toLowerCase() === instanceName) {
|
||||||
|
displayVendor = element.vendor;
|
||||||
|
displayModel = element.model;
|
||||||
|
}
|
||||||
|
});
|
||||||
displays.push({
|
displays.push({
|
||||||
vendor: instanceName.startsWith(deviceID) ? vendor : '',
|
vendor: instanceName.startsWith(deviceID) && displayVendor === '' ? vendor : displayVendor,
|
||||||
model: instanceName.startsWith(deviceID) ? model : '',
|
model: instanceName.startsWith(deviceID) && displayModel === '' ? model : displayModel,
|
||||||
main: primary.toLowerCase() === 'true',
|
main: primary.toLowerCase() === 'true',
|
||||||
builtin: videoOutputTechnology === '2147483648',
|
builtin: videoOutputTechnology === '2147483648',
|
||||||
connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
|
connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user