0

I want to write a Java program that waits for an input and takes an action (for example, play an mp3 file) based on the input. Specifically, I want to know how I can tell my java program when/what desktop applications are launched/currently running.

Practical application of this is that I basically want to play a different sound file when different applications are launched.

Additionally, I'd like to know if it is possible to have a Java program do this by manipulating an existing program (for example, play a sound file from Groove music).

Please direct me to any resources that would help me with these goals, I don't know if Java is the best language for this but it's the only one I know. Thank you!

Sean O
  • 1
  • In order to get the name of the opened app in Windows, you need JNA and you can find something interesting here: https://stackoverflow.com/questions/11067484/get-titles-of-non-java-windows-in-java/11067492#11067492, you can pool this list and when you get a new item in the list, if is the one , you play the Mp3... – navy1978 Jan 22 '18 at 15:37
  • why do you need to know what's open? Just launch the file and the system will use the default application for the extension or will pop up a dialog for the user to choose a program. See https://docs.oracle.com/javase/8/docs/api/java/lang/Process.html – daddygames Jan 22 '18 at 15:59
  • Possibly play a different sound for each file extension as opposed to which application will open the file? – daddygames Jan 22 '18 at 16:01
  • Thanks for the links, I'll check these out! @daddygames, an example of the practical application I'm looking for here is "if user started video game x, then play playlist y", or "if user opened microsoft word, stop playlist y and switch to playlist z" – Sean O Jan 22 '18 at 16:41

0 Answers0