This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to invoke 'PrtSc' Key in JAVA

 
Ramesh Kumar Swarnkar
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I need to invoke a 'PrtSc' command of keyboard from a Java program. So that it can capture the entire screen-contents as an image. The Java-code should be such that while running in a loop and it will capture the screen as image at every 2 seconds .

I will be very grateful if someone, on this intelligent forum, can suggest me the solution in JAVA.

looking forwards - thanks in advance !!!

Ramesh
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24204
34
Chrome Eclipse IDE Mac OS X
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The only way to use the keyboard's PrScr key would be to use a robot. With sensors and motors and such. No other way to physically press a key that I can think of!

But... if what you're actually interested in is making screen grabs, then just check out the createScreenCapture() method of the java.awt.Robot class.
 
Ramesh Kumar Swarnkar
Ranch Hand
Posts: 84
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let me check....robot
 
John de Michele
Rancher
Posts: 600
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or, you could look in the java.awt.event.KeyEvent class for KeyEvent.VK_PRINTSCREEN. If you needed to automate something, you could use that with Selenium to simulate a keypress of the Print Screen key.

John.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic