I made an application using java which takes and stores screenshots in the specified folder. I set the shortcut ctrl+K to take and save the screenshot and I managed to make my application minimize to system tray when minimize button of jframe is pressed, but the problem is the keyboard shortcut assigned doesn't works as soon as jframe is either minimized or is put in background by some other application, Is it possible to make d application work even when JFrame is not in focus? Please help! Thanks! (I am making the application for windows only)
Asked
Active
Viewed 703 times
1
-
1Windows won't send your Ctrl-K to any minimised windows. So nothing you can do in Java will give you what you want. – Dawood ibn Kareem May 30 '14 at 05:44
-
About the only solution you have would to use a JNI/JNA library that could monitor the global keystrokes been generated at a OS level – MadProgrammer May 30 '14 at 05:45
-
@MadProgrammer can u please give me any link to examples on how to use the JNI/JNA library u mentioned. Please. – user3626393 May 30 '14 at 06:12
-
I want to know that why my question was given -1??? I dint find any such previous question on stackoverflow. – user3626393 May 30 '14 at 06:36
-
You will probably never know who downvoted it or why. Not much you can do about it, but I don't see why it matters. You got the answer you wanted. – Dawood ibn Kareem May 30 '14 at 06:38
-
yeah but still sir, there should be a valid reason to downvote a question, but i guess some people are enjoy downvoting. anyways thanks to all! :) – user3626393 May 30 '14 at 06:40
1 Answers
2
For something like this i woud use 3th party lib like JNativeHook(I use it often) You can use Global listener nativehook
Here are some examples how to use it examples

Tomas Bisciak
- 2,801
- 5
- 33
- 57
-
Thanks for ur answer, i guess it would work but I want to ask a thing, the example shown involves the use of a single key as a shortcut while i want ctrl+k, can that be implemented using this library? – user3626393 May 30 '14 at 06:27
-
ofcourse,its almost same the way you are used to do it in swing. – Tomas Bisciak May 30 '14 at 06:33
-