Java uses machines to send keystrokes to humans
•
Java
I know that robot class can be used to send keystrokes in Java, but is there any way to specify the target process when it has been started?
Solution
The robot sends keystrokes to any application window at the top To send keystrokes to a specific target, you first need to set the target as the foreground window of the platform This may require native code, such as code provided by JNI or (I use) JNA If you want to send keystrokes to the background window, I believe you can't use robot. You must write native code Of course, all native code solutions will depend on the platform
You ask:
For windows, you will work with user32 DLL library Something like this works for me:
User32. java
JnaUtil. java
JnaUtilException. java
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码