Managing Windows Applications Using Java

I would like to know if there is a way to control a Windows application using Java code. I already found this in googled and found that it can be done using JNI or a library called NewJawin.

I want to control Windows Media Player using Java code, for example. play, pause and change songs, but could not find a suitable example to bring me so far. Do you have any suggestions?

+4
source share
1 answer

Since no one answered this question, I thought I wanted to.

public void firePlay() { //CTRL + P //import java.awt.Robot //import java.awt.KeyEvent try { Robot robot = new Robot(); robot.keyPress(KeyEvent.VK_CONTROL); robot.keyPress(KeyEvent.VK_P); robot.keyRelease(KeyEvent.VK_P); robot.keyRelease(KeyEvent.VK_CONTROL); } catch (AWTException ex) { Logger.getLogger(atest.class.getName()).log(Level.SEVERE, null, ex); } } 

This will play / pause the video. You can see other shortcuts here ( http://windows.microsoft.com/en-AU/windows-vista/Windows-Media-Player-keyboard-shortcuts )

+7
source