1、SetRes下载
下载地址:https://www.softpedia.com/get/Multimedia/Video/Other-VIDEO-Tools/Ian-Sharpe-SetRes.shtml
2、修改单屏代码
将下载的SetRes.exe拷到当前目录即可
//String homeDirectory = System.getProperty("user.home");
Process process;
process = Runtime.getRuntime()
.exec("cmd.exe /c setres h1920 v1080");
StreamGobbler streamGobbler =
new StreamGobbler(process.getInputStream(), System.out::println);
Executors.newSingleThreadExecutor().submit(streamGobbler);
int exitCode = process.waitFor();
assert exitCode == 0;
3、修改双屏代码
将下载的SetRes.exe拷到当前目录即可
//String homeDirectory = System.getProperty("user.home");
Process process;
process = Runtime.getRuntime()
.exec("cmd.exe /c SETRES m0:0 h1366 v768 && SETRES m1:0 h1280 v800");
StreamGobbler streamGobbler =
new StreamGobbler(process.getInputStream(), System.out::println);
Executors.newSingleThreadExecutor().submit(streamGobbler);
int exitCode = process.waitFor();
assert exitCode == 0;
相关文档:Java 通过ProcessBuilder或Runtime.exec()调用(cmd/sh)系统命令方法代码