0

Right, my title probably made no sense. However I'll explain it now.

I have a program coded in C++ that I wish to allow a keycombo to be pressed to run the program. My program does not run all the time it only runs when clicked then closes when the operation is complete. It simply does it's function then closes itself. Now here is the question.

Would it be simpler to attempt to edit my C++ program to run all the time via a thread in a class that then called the other class to run that did the function then stopped and listened for keypress again.

Or

Create a Java program that runs all the time and listens for a keyEvent and upon doing so runs the other programs exe. Then bundle the exe and jar in to one exe that is installed and run so they have access to each other. If I did it this way is it even possible as far as I know key events need to have focus to be able to be detected. Meaning that I would need to be running the program as my main window to detect it? Or is that not true.

I'd looked at the java route as my Java is better than my C++. Is this do-able and if so what approach would be the better one?

Hope this is explained well enough let me know otherwise.

Kyle93
  • 795
  • 5
  • 16
  • 26
  • You can use OS instruments to assign a hotkey to executable. There are hotkeys for Windows lnk files, Linux X server can be configured to handle those and modern Linux desktop evironments can do this via GUI too. – Basilevs Nov 24 '13 at 17:25
  • If you're running on Windows then you can look into creating a shortcut -> properties -> shortcut key. Otherwise, you're going to need a background program using a global key hook to detect when you should launch your application. – Warty Nov 24 '13 at 17:25
  • @Basilevs Thanks for the reply, I'd considered that however I'd prefer if possible to go with a solution like the original idea as that would allow me to add more ideas – Kyle93 Nov 24 '13 at 17:31
  • @ItzWarty As I said to Basilves I'd looked at that but would prefer to go another route. If I was to go with the background program what would you recommend it being written in? Would it be better to go with the Java or C++ implementation? – Kyle93 Nov 24 '13 at 17:32
  • 1
    @Kyle93: I'd expect you to need native calls, so C++ would be the way to go in my opinion. That being said, if Java has built-in functionality for that it's also an option. – Warty Nov 24 '13 at 18:00
  • 1
    It hasn't http://stackoverflow.com/questions/458756/java-system-wide-keyboard-shortcut – Basilevs Nov 24 '13 at 18:44

0 Answers0