graphics() rewrite for windows
This commit is contained in:
parent
e1dba93c56
commit
df6fc61694
@ -544,9 +544,9 @@ function graphics(callback) {
|
|||||||
const workload = [];
|
const workload = [];
|
||||||
workload.push(util.wmic('path win32_VideoController get /value'));
|
workload.push(util.wmic('path win32_VideoController get /value'));
|
||||||
workload.push(util.wmic('path win32_desktopmonitor get /value'));
|
workload.push(util.wmic('path win32_desktopmonitor get /value'));
|
||||||
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorBasicDisplayParams'));
|
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'));
|
workload.push(util.powerShell('Get-CimInstance -Namespace root\\wmi -ClassName WmiMonitorConnectionParams | fl'));
|
||||||
|
|
||||||
Promise.all(
|
Promise.all(
|
||||||
workload
|
workload
|
||||||
@ -558,6 +558,8 @@ function graphics(callback) {
|
|||||||
// displays
|
// displays
|
||||||
let dsections = data[1].split(/\n\s*\n/);
|
let dsections = data[1].split(/\n\s*\n/);
|
||||||
// result.displays = parseLinesWindowsDisplays(dsections);
|
// result.displays = parseLinesWindowsDisplays(dsections);
|
||||||
|
dsections.shift();
|
||||||
|
dsections.pop();
|
||||||
|
|
||||||
// monitor (powershell)
|
// monitor (powershell)
|
||||||
let msections = data[2].split('Active ');
|
let msections = data[2].split('Active ');
|
||||||
@ -566,12 +568,12 @@ function graphics(callback) {
|
|||||||
// forms.screens (powershell)
|
// forms.screens (powershell)
|
||||||
let ssections = data[3].split('BitsPerPixel ');
|
let ssections = data[3].split('BitsPerPixel ');
|
||||||
ssections.shift();
|
ssections.shift();
|
||||||
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections);
|
|
||||||
|
|
||||||
// connection params (powershell) - video type
|
// connection params (powershell) - video type
|
||||||
let tsections = data[4].split(/\n\s*\n/);
|
let tsections = data[4].split(/\n\s*\n/);
|
||||||
// tsections.shift();
|
tsections.shift();
|
||||||
console.log(tsections);
|
|
||||||
|
result.displays = parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections);
|
||||||
|
|
||||||
if (result.controllers.length === 1 && result.displays.length === 1) {
|
if (result.controllers.length === 1 && result.displays.length === 1) {
|
||||||
if (_resolutionx) {
|
if (_resolutionx) {
|
||||||
@ -661,16 +663,16 @@ function graphics(callback) {
|
|||||||
// return displays;
|
// return displays;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections) {
|
function parseLinesWindowsDisplaysPowershell(ssections, msections, dsections, tsections) {
|
||||||
let displays = [];
|
let displays = [];
|
||||||
let vendor = '';
|
let vendor = '';
|
||||||
let model = '';
|
let model = '';
|
||||||
let deviceID = '';
|
let deviceID = '';
|
||||||
if (dsections && dsections.length) {
|
if (dsections && dsections.length) {
|
||||||
let linesDsplay = dsections[0].split(os.EOL);
|
let linesDisplay = dsections[0].split(os.EOL);
|
||||||
vendor = util.getValue(linesDsplay, 'MonitorManufacturer', '=');
|
vendor = util.getValue(linesDisplay, 'MonitorManufacturer', '=');
|
||||||
model = util.getValue(linesDsplay, 'Name', '=');
|
model = util.getValue(linesDisplay, 'Name', '=');
|
||||||
deviceID = util.getValue(linesDsplay, 'PNPDeviceID', '=');
|
deviceID = util.getValue(linesDisplay, 'PNPDeviceID', '=').replace(/&/g, '&').toLowerCase();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < ssections.length; i++) {
|
for (let i = 0; i < ssections.length; i++) {
|
||||||
@ -680,18 +682,20 @@ function graphics(callback) {
|
|||||||
|
|
||||||
let linesScreen = ssections[i].split(os.EOL);
|
let linesScreen = ssections[i].split(os.EOL);
|
||||||
let linesMonitor = msections[i].split(os.EOL);
|
let linesMonitor = msections[i].split(os.EOL);
|
||||||
|
let linesConnection = tsections[i].split(os.EOL);
|
||||||
const bitsPerPixel = util.getValue(linesScreen, 'BitsPerPixel');
|
const bitsPerPixel = util.getValue(linesScreen, 'BitsPerPixel');
|
||||||
const bounds = util.getValue(linesScreen, 'Bounds').replace('{', '').replace('}', '').split(',');
|
const bounds = util.getValue(linesScreen, 'Bounds').replace('{', '').replace('}', '').split(',');
|
||||||
const primary = util.getValue(linesScreen, 'Primary');
|
const primary = util.getValue(linesScreen, 'Primary');
|
||||||
const sizex = util.getValue(linesMonitor, 'MaxHorizontalImageSize');
|
const sizex = util.getValue(linesMonitor, 'MaxHorizontalImageSize');
|
||||||
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
|
const sizey = util.getValue(linesMonitor, 'MaxVerticalImageSize');
|
||||||
const instanceName = util.getValue(linesMonitor, 'InstanceName');
|
const instanceName = util.getValue(linesMonitor, 'InstanceName').toLowerCase();
|
||||||
|
const videoOutputTechnology = util.getValue(linesConnection, 'VideoOutputTechnology');
|
||||||
displays.push({
|
displays.push({
|
||||||
vendor: instanceName === deviceID ? vendor : '',
|
vendor: instanceName.startsWith(deviceID) ? vendor : '',
|
||||||
model: instanceName === deviceID ? model : '',
|
model: instanceName.startsWith(deviceID) ? model : '',
|
||||||
main: primary.toLowerCase() === 'true',
|
main: primary.toLowerCase() === 'true',
|
||||||
builtin: false,
|
builtin: false,
|
||||||
connection: '',
|
connection: videoOutputTechnology && videoTypes[videoOutputTechnology] ? videoTypes[videoOutputTechnology] : '',
|
||||||
resolutionx: util.toInt(util.getValue(bounds, 'Width', '=')),
|
resolutionx: util.toInt(util.getValue(bounds, 'Width', '=')),
|
||||||
resolutiony: util.toInt(util.getValue(bounds, 'Height', '=')),
|
resolutiony: util.toInt(util.getValue(bounds, 'Height', '=')),
|
||||||
sizex: sizex ? parseInt(sizex, 10) : -1,
|
sizex: sizex ? parseInt(sizex, 10) : -1,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user