windows如何获取Java程序打开的外部应用程序的坐标
我使用Java程序打开一个外部应用程序(例如:记事本)。如何获取屏幕捕获/屏幕截图的外部应用程序的坐标/位置
我可以拍摄整个窗口的屏幕截图,但不能拍摄特定应用程序的屏幕截图
我已经尝试使用“Robot”进行屏幕捕获,但无法捕获特定区域,因为我无法找到应用程序窗口的位置和大小
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.lang.reflect.Field;
public class AppCheck {
public static void main(String[] args) {
System.out.println("***********************");
try {
System.out.println("Opening notepad");
Runtime runTime = Runtime.getRuntime();
Process process = runTime.exec("notepad");
try {
int count=0;
while(process.isAlive())
{
System.out.println("process name : " + process.getClass().getName());
Field f = process.getClass().getDeclaredField("handle");
f.setAccessible(true);
long handl = f.getLong(process);
System.out.println("Process ID : " + handl);
Thread.sleep(1000);
}
} catch (InterruptedException e) {
e.printStackTrace();
}
System.out.println("Closing notepad");
process.destroy();
} catch (Exception ex) {
System.out.println(ex);
}
System.out.println("************************************");
}
}
共 (0) 个答案