• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Sending key strokes to Windows App

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
reply
    Bookmark Topic Watch Topic
  • New Topic