简体   繁体   English

是否有用于访问外部窗口的Java库?

[英]Is there a Java library for access external windows?

I'm trying to build an app that takes a screenshot of specific program that's open(an external program, one that I did not code), but my research just keeps pointing me to c++. 我正在尝试构建一个应用程序,该应用程序使用打开的特定程序(一个外部程序,我未编写代码)的屏幕截图,但是我的研究一直在使我指向c ++。 I was curious if there's a way to do this, or access Windows stuff in general from Java, or if I just need to jump to a scripting language or C. Thank you. 我很好奇是否有办法做到这一点,或者可以从Java访问Windows的一般功能,还是只需要跳转到脚本语言或C。谢谢。

it depends, here is what I found so far. 这取决于我到目前为止所发现的。

you can access process names listed on the Task Manager via the Runtime object found here 您可以通过此处找到的Runtime对象访问任务管理器上列出的进程名称

an explanation on how to use it is on stackoverflow already here . 关于如何使用它的解释是计算器已经在这里 but you need to know the name of the app you want to find, such as mspaint.exe, msword.exe, myprogram.exe, and so on... 但是您需要知道要查找的应用程序的名称,例如mspaint.exe,msword.exe,myprogram.exe等。

now if you know the executable name, and the application happens to be running, you can use Java's Robot library to get a 'screenshot'. 现在,如果您知道可执行文件的名称,并且应用程序恰好正在运行,则可以使用Java的Robot库获取“屏幕快照”。 the java API library for Robot is found here and an example of how to use it can be found here . 为Java API库Robot发现这里和如何使用它的例子可以发现在这里 The stackoverflow answer goes into details about using Robot vs another custom tailored approach to just getting a screenshot. stackoverflow答案详细介绍了如何使用Robot与另一种定制方法来获取屏幕截图。

Also note that the pages i linked to are for Java 7, there is also a Java 8 library found here which would be the more current version. 另外请注意,我挂是为Java 7的网页,也有发现一个Java 8图书馆这里这将是更多的当前版本。

I usually just google "java api X" and whatever I'm looking for. 我通常只用谷歌“ java api X”和我想要的任何东西。

hope that helps. 希望能有所帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM