• Post Reply Bookmark Topic Watch Topic
  • New Topic

Sending key strokes to Windows App

 
Servin Park
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have been searching for a way to send key strokes to windows app such as Word with Java. Many people pointed to Robot class, but it doesn't have way to set focus to windows app and send key strokes as far as I know. Is it really impossible with Java? Any help can be greatly appreciated. Thank you.
 
Servin Park
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Finally, I have my first JNI programming working. After posting the original message, I have researched in JNI direction. Thanks to "NO REPLIES!!!", I was able to get some basic functionalities working. So let me know if anyone need to use it or just want to play around with it.
Please note that the following class and dll doesn't implement function keys and special keys yet. For now, it is only able to send a string to notepad or word, probably DOS as well.
************************************************
Win32User.class - calls native functions
- There is only one public function sendKeyToApp(String title, String content)
win32user.dll - implements native functions
To use, place them in a directory and create a main class with something like this:
Win32User w32u = new Win32User();
w32u.sendKeysToApp("Microsoft Word - Document1", "Hello, how are you doing? I'm fine~");
Notice ~(tilda) at the end of second parameter. ~ acts as {ENTER} key.
[ May 20, 2002: Message edited by: Servin Park ]
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!