[英]Java - Get title of active window
I need to get title of current active window(for example right now: Google Chrome).我需要获取当前活动窗口的标题(例如现在:Google Chrome)。 I search smth in internet, and found only this javax.swing.FocusManager.getCurrentManager().getActiveWindow();
我在互联网上搜索,只找到了这个javax.swing.FocusManager.getCurrentManager().getActiveWindow();
. . But i don't know how to get PROGRAM TITLE with that code.但我不知道如何使用该代码获得程序标题。
If you are fine with a non-java solution that will work for Windows computers, there is a programming language called AutoHotkey (AHK) that is more suited for this kind of task.如果您对适用于 Windows 计算机的非 Java 解决方案感到满意,则有一种称为 AutoHotkey (AHK) 的编程语言更适合此类任务。 There exists a popular script called "Window Spy" (also known as "ActiveWindowInfo") that has the ability to view the title of the active window, as well as other information such as PID, the name of the .exe that the Window is an instance of, and etc. (I have attached a screenshot of what Window Spy told about the Google Chrome window I was using to write this reply. In the screenshot, I have also indicated which part of it tells you the Title of the Window).存在一个名为“Window Spy”(也称为“ActiveWindowInfo”)的流行脚本,它能够查看活动窗口的标题,以及其他信息,例如 PID、窗口所在的 .exe 的名称等的一个实例(我附上了 Window Spy 告诉我的关于 Google Chrome 窗口我用来写这个回复的截图。在截图中,我还指出了它的哪一部分告诉你窗口的标题)。
This script comes with most AutoHotkey IDEs (such as SciTe4Autohotkey if you are interested).该脚本随大多数 AutoHotkey IDE 一起提供(如果您感兴趣,例如 SciTe4Autohotkey)。 However, you can perfectly well run the script without an IDE.但是,您可以在没有 IDE 的情况下完美地运行脚本。
Here are some quickstart instructions:以下是一些快速入门说明:
If you need any more info on how to use the script, please let me know.如果您需要有关如何使用脚本的更多信息,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.