I am trying to upgrade my application in Java to work only if a window of process with certain name is active. I have found out that this is possible by using JNI, but I have no idea how exactly to do that. I just could not find any description or example that would explain it. My question is - how to get process name of currently active window in Windows (via JNI, or anything else - I accept any another solution)?
相关问题
- Delete Messages from a Topic in Apache Kafka
- Jackson Deserialization not calling deserialize on
- How to maintain order of key-value in DataFrame sa
- StackExchange API - Deserialize Date in JSON Respo
- Difference between Types.INTEGER and Types.NULL in
This code works with JNA 4.0
Save yourself some pain and use JNA. You will need to download jna.jar and jna-platform.jar for the Win32 API. The pinvoke wiki and MSDN are useful for finding the right system calls.
Anyway, here is the code to print the title and process of the currently active window.