Last active
February 27, 2016 17:08
-
-
Save hmbrg/e8cdfdc53a8e8b2ae3a8 to your computer and use it in GitHub Desktop.
Get screen resulution on windows using node
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const spawn = require('child_process').spawn; | |
| const bat = spawn('cmd.exe', ['/c', __dirname + '/getScreenRes.bat']); | |
| bat.stdout.setEncoding('utf8'); | |
| var out = ""; | |
| bat.stdout.on('data', (data) => { | |
| out = out + data; | |
| }); | |
| bat.stderr.on('data', (data) => { | |
| out = out + data; | |
| }); | |
| bat.on('exit', (code) => { | |
| const arrout = out.split("\n"); | |
| console.log(arrout[0]); | |
| console.log(arrout[1]); | |
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @echo off | |
| for /f "delims=" %%# in ('"wmic path Win32_VideoController get CurrentHorizontalResolution,CurrentVerticalResolution /format:value"') do ( | |
| set "%%#">nul | |
| ) | |
| echo %CurrentHorizontalResolution% | |
| echo %CurrentVerticalResolution% |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment