Talrijke aanpassingen gemaakt. Vorige commit gaf een fout en ik heb geen zin om informatie opnieuw te typen.
This commit is contained in:
@@ -150,5 +150,19 @@ public class ITPlaylist extends ITObject {
|
||||
Dispatch tracks = Dispatch.get(object, "Tracks").toDispatch();
|
||||
return new ITTrackCollection(tracks);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the shuffle state.
|
||||
* @return true if current state is shuffle.
|
||||
*/
|
||||
public boolean getShuffle() {
|
||||
return Dispatch.get(object, "Shuffle").getBoolean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the shuffle state.
|
||||
*/
|
||||
public void toggleShuffle() {
|
||||
setShuffle(!getShuffle());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -342,6 +342,13 @@ public class iTunes {
|
||||
setMute(!getMute());
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the shuffle state.
|
||||
*/
|
||||
public void toggleShuffle() {
|
||||
getCurrentPlaylist().toggleShuffle();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current player state.
|
||||
* @return Returns the current player state.
|
||||
|
||||
@@ -332,10 +332,10 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
||||
ui.getAcExit().removeActionListener(this);
|
||||
ui.getAcExit().addActionListener(this);
|
||||
// DSP
|
||||
if (ui.getAcAnalyzer() != null)
|
||||
/*if (ui.getAcAnalyzer() != null)
|
||||
{
|
||||
add(ui.getAcAnalyzer(), ui.getAcAnalyzer().getConstraints());
|
||||
}
|
||||
}*/
|
||||
// Popup menu
|
||||
mainpopup = new JPopupMenu(ui.getResource("popup.title"));
|
||||
JMenuItem mi = new JMenuItem(Skin.TITLETEXT + "- JavaZOOM");
|
||||
@@ -1173,14 +1173,14 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
||||
{
|
||||
lastScrollTime = System.currentTimeMillis();
|
||||
posValueJump = false;
|
||||
if (audioInfo.containsKey("basicplayer.sourcedataline"))
|
||||
/*if (audioInfo.containsKey("basicplayer.sourcedataline"))
|
||||
{
|
||||
if (ui.getAcAnalyzer() != null)
|
||||
{
|
||||
ui.getAcAnalyzer().setupDSP((SourceDataLine) audioInfo.get("basicplayer.sourcedataline"));
|
||||
ui.getAcAnalyzer().startDSP((SourceDataLine) audioInfo.get("basicplayer.sourcedataline"));
|
||||
}
|
||||
}
|
||||
}*/
|
||||
}
|
||||
else if (state == BasicPlayerEvent.SEEKING)
|
||||
{
|
||||
@@ -1207,11 +1207,11 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
||||
}
|
||||
else if (state == BasicPlayerEvent.STOPPED)
|
||||
{
|
||||
if (ui.getAcAnalyzer() != null)
|
||||
/*if (ui.getAcAnalyzer() != null)
|
||||
{
|
||||
ui.getAcAnalyzer().stopDSP();
|
||||
ui.getAcAnalyzer().repaint();
|
||||
}
|
||||
}*/
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1236,7 +1236,7 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
||||
if (audioInfo.containsKey("basicplayer.sourcedataline"))
|
||||
{
|
||||
// Spectrum/time analyzer
|
||||
if (ui.getAcAnalyzer() != null) ui.getAcAnalyzer().writeDSP(pcmdata);
|
||||
//if (ui.getAcAnalyzer() != null) ui.getAcAnalyzer().writeDSP(pcmdata);
|
||||
}
|
||||
if (audioInfo.containsKey("audio.length.bytes"))
|
||||
{
|
||||
@@ -1699,12 +1699,12 @@ public class PlayerUI extends JPanel implements ActionListener, ChangeListener,
|
||||
{
|
||||
config.setAudioDevice(((BasicPlayer) theSoundPlayer).getMixerName());
|
||||
}
|
||||
if (ui.getAcAnalyzer() != null)
|
||||
/*if (ui.getAcAnalyzer() != null)
|
||||
{
|
||||
if (ui.getAcAnalyzer().getDisplayMode() == SpectrumTimeAnalyzer.DISPLAY_MODE_OFF) config.setVisualMode("off");
|
||||
else if (ui.getAcAnalyzer().getDisplayMode() == SpectrumTimeAnalyzer.DISPLAY_MODE_SCOPE) config.setVisualMode("oscillo");
|
||||
else config.setVisualMode("spectrum");
|
||||
}
|
||||
}*/
|
||||
if (playlist != null)
|
||||
{
|
||||
playlist.save("default.m3u");
|
||||
|
||||
@@ -40,7 +40,7 @@ import javax.swing.JSlider;
|
||||
import javazoom.jlgui.player.amp.PlayerActionEvent;
|
||||
import javazoom.jlgui.player.amp.equalizer.ui.SplinePanel;
|
||||
import javazoom.jlgui.player.amp.util.Config;
|
||||
import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer;
|
||||
//import javazoom.jlgui.player.amp.visual.ui.SpectrumTimeAnalyzer;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
@@ -196,7 +196,7 @@ public class Skin
|
||||
private String viscolor = null;
|
||||
private int[] visualLocation = { 24, 44 };
|
||||
private int[] visualSize = { 76, 15 };
|
||||
private SpectrumTimeAnalyzer analyzer = null;
|
||||
//private SpectrumTimeAnalyzer analyzer = null;
|
||||
/*-- EqualizerUI --*/
|
||||
private Image imFullEqualizer = null;
|
||||
private Image imEqualizer = null;
|
||||
@@ -473,7 +473,7 @@ public class Skin
|
||||
acTimeIcon.setIcons(timeIcons);
|
||||
acTimeIcon.setConstraints(new AbsoluteConstraints(iconsLocation[2], iconsLocation[3]));
|
||||
/*-- DSP --*/
|
||||
setAnalyzerPanel();
|
||||
//setAnalyzerPanel();
|
||||
/*-- Pos Bar --*/
|
||||
readPanel(releasedPosIm, releasedPosPanel, pressedPosIm, pressedPosPanel, imPosBar);
|
||||
setPosBarPanel();
|
||||
@@ -724,7 +724,7 @@ public class Skin
|
||||
{
|
||||
log.info("DSP disabled");
|
||||
}
|
||||
else
|
||||
/*else
|
||||
{
|
||||
if (analyzer == null) analyzer = new SpectrumTimeAnalyzer();
|
||||
String visualMode = config.getVisualMode();
|
||||
@@ -745,7 +745,7 @@ public class Skin
|
||||
analyzer.setPeakDelay((int) (fps * SpectrumTimeAnalyzer.DEFAULT_SPECTRUM_ANALYSER_PEAK_DELAY_FPS_RATIO));
|
||||
analyzer.setConstraints(new AbsoluteConstraints(visualLocation[0], visualLocation[1], visualSize[0], visualSize[1]));
|
||||
analyzer.setToolTipText(getResource("panel.analyzer"));
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1343,10 +1343,10 @@ public class Skin
|
||||
return acSecondL;
|
||||
}
|
||||
|
||||
public SpectrumTimeAnalyzer getAcAnalyzer()
|
||||
/*public SpectrumTimeAnalyzer getAcAnalyzer()
|
||||
{
|
||||
return analyzer;
|
||||
}
|
||||
}*/
|
||||
|
||||
public ActiveJButton getAcEqPresets()
|
||||
{
|
||||
|
||||
@@ -15,5 +15,5 @@ public enum Action {
|
||||
TEST,
|
||||
VOLUME_DOWN,
|
||||
VOLUME_UP,
|
||||
TRAIN, STOP, SAVE, RECOGNIZE, LOAD;
|
||||
TRAIN, STOP, SAVE, RECOGNIZE, LOAD, SHUFFLE;
|
||||
}
|
||||
|
||||
@@ -6,12 +6,11 @@ import pm.task.TaskGatherer;
|
||||
import pm.task.TaskListener;
|
||||
|
||||
public abstract class Application extends TaskListener {
|
||||
|
||||
public Application() {
|
||||
super();
|
||||
TaskGatherer.add(this);
|
||||
}
|
||||
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
initialise();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package pm;
|
||||
|
||||
import pm.exception.application.ApplicationExitException;
|
||||
import pm.exception.device.DeviceExitException;
|
||||
import pm.exception.device.DeviceInitialiseException;
|
||||
import pm.macro.Event;
|
||||
|
||||
@@ -6,10 +6,13 @@ import pm.application.ApplicationCycle;
|
||||
import pm.application.Winamp.WinampApplication;
|
||||
import pm.application.example.ExampleApplication;
|
||||
import pm.application.iTunes.iTunesApplication;
|
||||
import pm.application.windows.gomplayer.GomPlayerApplication;
|
||||
import pm.application.windows.wmp.WMPApplication;
|
||||
import pm.device.gui.GUIDevice;
|
||||
import pm.device.javainput.rumblepad.RumblepadDevice;
|
||||
import pm.device.jintellitype.JIntellitypeDevice;
|
||||
import pm.device.lantextinput.LanTextDevice;
|
||||
import pm.device.player.PlayerDevice;
|
||||
import pm.device.textinput.TextDevice;
|
||||
import pm.device.wiimote.WiimoteDevice;
|
||||
import pm.exception.application.ApplicationExitException;
|
||||
@@ -17,7 +20,6 @@ import pm.exception.device.DeviceExitException;
|
||||
import pm.exception.device.DeviceInitialiseException;
|
||||
import pm.task.TaskGatherer;
|
||||
import pm.task.TaskListener;
|
||||
import pm.util.ArrayCycle;
|
||||
|
||||
public class Main extends TaskListener {
|
||||
//protected String[] deviceClassArray;
|
||||
@@ -39,8 +41,9 @@ public class Main extends TaskListener {
|
||||
|
||||
public void initialise() throws DeviceInitialiseException {
|
||||
add(new JIntellitypeDevice());
|
||||
//add(new PlayerDevice());
|
||||
//add(new RumblepadDevice());
|
||||
//add(new WiimoteDevice());
|
||||
add(new WiimoteDevice());
|
||||
//add(new GUIDevice());
|
||||
//add(new TextDevice());
|
||||
//add(new LanTextDevice());
|
||||
@@ -52,10 +55,11 @@ public class Main extends TaskListener {
|
||||
}
|
||||
}
|
||||
|
||||
add(new ExampleApplication());
|
||||
//add(new ExampleApplication());
|
||||
//add(new WMPApplication());
|
||||
add(new GomPlayerApplication());
|
||||
//add(new WinampApplication());
|
||||
//add(new iTunesApplication());
|
||||
applicationCycle.next();
|
||||
for (Application application : applicationCycle) {
|
||||
application.start();
|
||||
}
|
||||
@@ -87,6 +91,7 @@ public class Main extends TaskListener {
|
||||
switch (action) {
|
||||
case NEXT:
|
||||
applicationCycle.next();
|
||||
System.out.println(applicationCycle.current());
|
||||
break;
|
||||
case PREVIOUS:
|
||||
applicationCycle.previous();
|
||||
|
||||
@@ -41,6 +41,7 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
||||
switch (action) {
|
||||
case PLAY:
|
||||
iTunes.playPause();
|
||||
break;
|
||||
case NEXT:
|
||||
iTunes.nextTrack();
|
||||
break;
|
||||
@@ -62,7 +63,10 @@ public class iTunesApplication extends Application implements iTunesEventsInterf
|
||||
case VOLUME_DOWN:
|
||||
iTunes.setSoundVolume(getVolume() - VOLUME_CHANGE_RATE);
|
||||
break;
|
||||
}
|
||||
case SHUFFLE:
|
||||
iTunes.toggleShuffle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
protected int getVolume() {
|
||||
|
||||
68
java/src/pm/application/windows/Command.java
Normal file
68
java/src/pm/application/windows/Command.java
Normal file
@@ -0,0 +1,68 @@
|
||||
package pm.application.windows;
|
||||
|
||||
public enum Command {
|
||||
BROWSER_BACKWARD (1),
|
||||
BROWSER_FORWARD (2),
|
||||
BROWSER_REFRESH (3),
|
||||
BROWSER_STOP (4),
|
||||
BROWSER_SEARCH (5),
|
||||
BROWSER_FAVORITES (6),
|
||||
BROWSER_HOME (7),
|
||||
VOLUME_MUTE (8),
|
||||
VOLUME_DOWN (9),
|
||||
VOLUME_UP (10),
|
||||
MEDIA_NEXTTRACK (11),
|
||||
MEDIA_PREVIOUSTRACK (12),
|
||||
MEDIA_STOP (13),
|
||||
MEDIA_PLAY_PAUSE (14),
|
||||
LAUNCH_MAIL (15),
|
||||
LAUNCH_MEDIA_SELECT (16),
|
||||
LAUNCH_APP1 (17),
|
||||
LAUNCH_APP2 (18),
|
||||
BASS_DOWN (19),
|
||||
BASS_BOOST (20),
|
||||
BASS_UP (21),
|
||||
TREBLE_DOWN (22),
|
||||
TREBLE_UP (23),
|
||||
MICROPHONE_VOLUME_MUTE (24),
|
||||
MICROPHONE_VOLUME_DOWN (25),
|
||||
MICROPHONE_VOLUME_UP (26),
|
||||
HELP (27),
|
||||
FIND (28),
|
||||
NEW (29),
|
||||
OPEN (30),
|
||||
CLOSE (31),
|
||||
SAVE (32),
|
||||
PRINT (33),
|
||||
UNDO (34),
|
||||
REDO (35),
|
||||
COPY (36),
|
||||
CUT (37),
|
||||
PASTE (38),
|
||||
REPLY_TO_MAIL (39),
|
||||
FORWARD_MAIL (40),
|
||||
SEND_MAIL (41),
|
||||
SPELL_CHECK (42),
|
||||
DICTATE_OR_COMMAND_CONTROL_TOGGLE (43),
|
||||
MIC_ON_OFF_TOGGLE (44),
|
||||
CORRECTION_LIST (45),
|
||||
MEDIA_PLAY (46),
|
||||
MEDIA_PAUSE (47),
|
||||
MEDIA_RECORD (48),
|
||||
MEDIA_FAST_FORWARD (49),
|
||||
MEDIA_REWIND (50),
|
||||
MEDIA_CHANNEL_UP (51),
|
||||
MEDIA_CHANNEL_DOWN (52),
|
||||
DELETE (53),
|
||||
DWM_FLIP3D (54);
|
||||
|
||||
protected int code;
|
||||
|
||||
private Command(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
||||
181
java/src/pm/application/windows/VirtualKey.java
Normal file
181
java/src/pm/application/windows/VirtualKey.java
Normal file
@@ -0,0 +1,181 @@
|
||||
package pm.application.windows;
|
||||
|
||||
public enum VirtualKey {
|
||||
/*
|
||||
* VK_0 - VK_9 are the same as ASCII '0' - '9' (0x30 - 0x39)
|
||||
* 0x40 : unassigned
|
||||
* VK_A - VK_Z are the same as ASCII 'A' - 'Z' (0x41 - 0x5A)
|
||||
*/
|
||||
LBUTTON (0x01),
|
||||
RBUTTON (0x02),
|
||||
CANCEL (0x03),
|
||||
MBUTTON (0x04),
|
||||
XBUTTON1 (0x05),
|
||||
XBUTTON2 (0x06),
|
||||
BACK (0x08),
|
||||
TAB (0x09),
|
||||
CLEAR (0x0C),
|
||||
RETURN (0x0D),
|
||||
SHIFT (0x10),
|
||||
CONTROL (0x11),
|
||||
MENU (0x12),
|
||||
PAUSE (0x13),
|
||||
CAPITAL (0x14),
|
||||
KANA (0x15),
|
||||
HANGEUL (0x15),
|
||||
HANGUL (0x15),
|
||||
JUNJA (0x17),
|
||||
FINAL (0x18),
|
||||
HANJA (0x19),
|
||||
KANJI (0x19),
|
||||
ESCAPE (0x1B),
|
||||
CONVERT (0x1C),
|
||||
NONCONVERT (0x1D),
|
||||
ACCEPT (0x1E),
|
||||
MODECHANGE (0x1F),
|
||||
SPACE (0x20),
|
||||
PRIOR (0x21),
|
||||
NEXT (0x22),
|
||||
END (0x23),
|
||||
HOME (0x24),
|
||||
LEFT (0x25),
|
||||
UP (0x26),
|
||||
RIGHT (0x27),
|
||||
DOWN (0x28),
|
||||
SELECT (0x29),
|
||||
PRINT (0x2A),
|
||||
EXECUTE (0x2B),
|
||||
SNAPSHOT (0x2C),
|
||||
INSERT (0x2D),
|
||||
DELETE (0x2E),
|
||||
HELP (0x2F),
|
||||
LWIN (0x5B),
|
||||
RWIN (0x5C),
|
||||
APPS (0x5D),
|
||||
SLEEP (0x5F),
|
||||
NUMPAD0 (0x60),
|
||||
NUMPAD1 (0x61),
|
||||
NUMPAD2 (0x62),
|
||||
NUMPAD3 (0x63),
|
||||
NUMPAD4 (0x64),
|
||||
NUMPAD5 (0x65),
|
||||
NUMPAD6 (0x66),
|
||||
NUMPAD7 (0x67),
|
||||
NUMPAD8 (0x68),
|
||||
NUMPAD9 (0x69),
|
||||
MULTIPLY (0x6A),
|
||||
ADD (0x6B),
|
||||
SEPARATOR (0x6C),
|
||||
SUBTRACT (0x6D),
|
||||
DECIMAL (0x6E),
|
||||
DIVIDE (0x6F),
|
||||
F1 (0x70),
|
||||
F2 (0x71),
|
||||
F3 (0x72),
|
||||
F4 (0x73),
|
||||
F5 (0x74),
|
||||
F6 (0x75),
|
||||
F7 (0x76),
|
||||
F8 (0x77),
|
||||
F9 (0x78),
|
||||
F10 (0x79),
|
||||
F11 (0x7A),
|
||||
F12 (0x7B),
|
||||
F13 (0x7C),
|
||||
F14 (0x7D),
|
||||
F15 (0x7E),
|
||||
F16 (0x7F),
|
||||
F17 (0x80),
|
||||
F18 (0x81),
|
||||
F19 (0x82),
|
||||
F20 (0x83),
|
||||
F21 (0x84),
|
||||
F22 (0x85),
|
||||
F23 (0x86),
|
||||
F24 (0x87),
|
||||
NUMLOCK (0x90),
|
||||
SCROLL (0x91),
|
||||
OEM_NEC_EQUAL (0x92),
|
||||
OEM_FJ_JISHO (0x92),
|
||||
OEM_FJ_MASSHOU (0x93),
|
||||
OEM_FJ_TOUROKU (0x94),
|
||||
OEM_FJ_LOYA (0x95),
|
||||
OEM_FJ_ROYA (0x96),
|
||||
LSHIFT (0xA0),
|
||||
RSHIFT (0xA1),
|
||||
LCONTROL (0xA2),
|
||||
RCONTROL (0xA3),
|
||||
LMENU (0xA4),
|
||||
RMENU (0xA5),
|
||||
BROWSER_BACK (0xA6),
|
||||
BROWSER_FORWARD (0xA7),
|
||||
BROWSER_REFRESH (0xA8),
|
||||
BROWSER_STOP (0xA9),
|
||||
BROWSER_SEARCH (0xAA),
|
||||
BROWSER_FAVORITES (0xAB),
|
||||
BROWSER_HOME (0xAC),
|
||||
VOLUME_MUTE (0xAD),
|
||||
VOLUME_DOWN (0xAE),
|
||||
VOLUME_UP (0xAF),
|
||||
MEDIA_NEXT_TRACK (0xB0),
|
||||
MEDIA_PREV_TRACK (0xB1),
|
||||
MEDIA_STOP (0xB2),
|
||||
MEDIA_PLAY_PAUSE (0xB3),
|
||||
LAUNCH_MAIL (0xB4),
|
||||
LAUNCH_MEDIA_SELECT (0xB5),
|
||||
LAUNCH_APP1 (0xB6),
|
||||
LAUNCH_APP2 (0xB7),
|
||||
OEM_1 (0xBA),
|
||||
OEM_PLUS (0xBB),
|
||||
OEM_COMMA (0xBC),
|
||||
OEM_MINUS (0xBD),
|
||||
OEM_PERIOD (0xBE),
|
||||
OEM_2 (0xBF),
|
||||
OEM_3 (0xC0),
|
||||
OEM_4 (0xDB),
|
||||
OEM_5 (0xDC),
|
||||
OEM_6 (0xDD),
|
||||
OEM_7 (0xDE),
|
||||
OEM_8 (0xDF),
|
||||
OEM_AX (0xE1),
|
||||
OEM_102 (0xE2),
|
||||
ICO_HELP (0xE3),
|
||||
ICO_00 (0xE4),
|
||||
PROCESSKEY (0xE5),
|
||||
ICO_CLEAR (0xE6),
|
||||
PACKET (0xE7),
|
||||
OEM_RESET (0xE9),
|
||||
OEM_JUMP (0xEA),
|
||||
OEM_PA1 (0xEB),
|
||||
OEM_PA2 (0xEC),
|
||||
OEM_PA3 (0xED),
|
||||
OEM_WSCTRL (0xEE),
|
||||
OEM_CUSEL (0xEF),
|
||||
OEM_ATTN (0xF0),
|
||||
OEM_FINISH (0xF1),
|
||||
OEM_COPY (0xF2),
|
||||
OEM_AUTO (0xF3),
|
||||
OEM_ENLW (0xF4),
|
||||
OEM_BACKTAB (0xF5),
|
||||
ATTN (0xF6),
|
||||
CRSEL (0xF7),
|
||||
EXSEL (0xF8),
|
||||
EREOF (0xF9),
|
||||
PLAY (0xFA),
|
||||
ZOOM (0xFB),
|
||||
NONAME (0xFC),
|
||||
PA1 (0xFD),
|
||||
OEM_CLEAR (0xFE);
|
||||
|
||||
|
||||
protected int code;
|
||||
|
||||
private VirtualKey(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
}
|
||||
106
java/src/pm/application/windows/WindowsApplication.java
Normal file
106
java/src/pm/application/windows/WindowsApplication.java
Normal file
@@ -0,0 +1,106 @@
|
||||
package pm.application.windows;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import com.eaio.nativecall.IntCall;
|
||||
import com.eaio.nativecall.NativeCall;
|
||||
|
||||
import pm.Application;
|
||||
import pm.exception.application.ApplicationExitException;
|
||||
import pm.exception.application.ApplicationInitialiseException;
|
||||
import pm.exception.application.windows.SendCommandException;
|
||||
import pm.exception.application.windows.SendKeyException;
|
||||
import pm.util.Native;
|
||||
import pm.util.VBScript;
|
||||
|
||||
abstract public class WindowsApplication extends Application {
|
||||
protected final static int TERMINATE_SLEEP = 500;
|
||||
protected final static int START_SLEEP = 500;
|
||||
|
||||
protected final static int WM_APPCOMMAND = 0x0319;
|
||||
protected final static int WM_KEYDOWN = 0x0100;
|
||||
|
||||
protected String path;
|
||||
protected String program;
|
||||
protected String name;
|
||||
protected String target;
|
||||
|
||||
protected Process process;
|
||||
protected int handle;
|
||||
protected IntCall sendMessage;
|
||||
protected IntCall postMessage;
|
||||
|
||||
static {
|
||||
try {
|
||||
NativeCall.init();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public WindowsApplication(String path, String program, String name) {
|
||||
this.path = path;
|
||||
this.program = program;
|
||||
this.name = name;
|
||||
target = path + program;
|
||||
handle = -1;
|
||||
}
|
||||
|
||||
public void initialise() throws ApplicationInitialiseException {
|
||||
try {
|
||||
if (VBScript.isRunning(program)) {
|
||||
handle = Native.getHandle(name);
|
||||
if (handle < 0) {
|
||||
while (VBScript.isRunning(program)) {
|
||||
VBScript.terminate(program);
|
||||
sleep(TERMINATE_SLEEP);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (handle < 0) {
|
||||
process = Runtime.getRuntime().exec(target);
|
||||
while (!VBScript.isRunning(program)) {
|
||||
sleep(START_SLEEP);
|
||||
}
|
||||
IntCall findWindow = new IntCall("user32", "FindWindowA");
|
||||
handle = findWindow.executeCall(new Object[] {null, name});
|
||||
}
|
||||
} catch (IOException e) {}
|
||||
if (handle < 1) {
|
||||
throw new ApplicationInitialiseException();
|
||||
}
|
||||
sendMessage = new IntCall("user32", "SendMessageA");
|
||||
postMessage = new IntCall("user32", "PostMessageA");
|
||||
}
|
||||
|
||||
public void exit() throws ApplicationExitException {
|
||||
if (process != null) {
|
||||
process.destroy();
|
||||
}
|
||||
super.exit();
|
||||
}
|
||||
|
||||
protected void command(Command command) throws SendCommandException {
|
||||
int result = sendMessage.executeCall(new Object[] {
|
||||
handle, WM_APPCOMMAND, handle, command.getCode() << 16});
|
||||
if (result < 1 || sendMessage.getLastError() != null) {
|
||||
throw new SendCommandException();
|
||||
}
|
||||
}
|
||||
|
||||
protected void key(int key) throws SendKeyException {
|
||||
int result = postMessage.executeCall(new Object[] {
|
||||
handle, WM_KEYDOWN, key});
|
||||
if (result < 1 || postMessage.getLastError() != null) {
|
||||
throw new SendKeyException();
|
||||
}
|
||||
}
|
||||
|
||||
protected void key(char key) throws SendKeyException {
|
||||
key((int) Character.toUpperCase(key));
|
||||
}
|
||||
|
||||
protected void key(VirtualKey virtualKey) throws SendKeyException {
|
||||
key(virtualKey.getCode());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package pm.application.windows.gomplayer;
|
||||
|
||||
import pm.Action;
|
||||
import pm.application.windows.Command;
|
||||
import pm.application.windows.VirtualKey;
|
||||
import pm.application.windows.WindowsApplication;
|
||||
import pm.exception.application.ApplicationInitialiseException;
|
||||
import pm.exception.application.windows.SendCommandException;
|
||||
import pm.exception.application.windows.SendKeyException;
|
||||
|
||||
public class GomPlayerApplication extends WindowsApplication {
|
||||
protected final static String PATH = "C:\\Program Files (x86)\\GRETECH\\GomPlayer\\";
|
||||
protected final static String PROGRAM = "GOM.exe";
|
||||
protected final static String NAME = "GOM Player";
|
||||
|
||||
protected boolean playing;
|
||||
|
||||
public GomPlayerApplication() {
|
||||
super(PATH, PROGRAM, NAME);
|
||||
playing = false;
|
||||
}
|
||||
|
||||
public void initialise() {
|
||||
try {
|
||||
super.initialise();
|
||||
} catch (ApplicationInitialiseException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void action(Action action) {
|
||||
System.out.println("GomPlayerApplication: " + action);
|
||||
//http://www.keyxl.com/aaa0602/267/GOM-Player-keyboard-shortcuts.htm
|
||||
try {
|
||||
switch (action) {
|
||||
case PLAY:
|
||||
key(VirtualKey.SPACE);
|
||||
break;
|
||||
case NEXT:
|
||||
command(Command.MEDIA_NEXTTRACK);
|
||||
break;
|
||||
case PREVIOUS:
|
||||
command(Command.MEDIA_PREVIOUSTRACK);
|
||||
break;
|
||||
case FORWARD:
|
||||
command(Command.MEDIA_FAST_FORWARD);
|
||||
break;
|
||||
case REWIND:
|
||||
command(Command.MEDIA_REWIND);
|
||||
break;
|
||||
case MUTE:
|
||||
key('m');
|
||||
break;
|
||||
case VOLUME_UP:
|
||||
key(VirtualKey.UP);
|
||||
break;
|
||||
case VOLUME_DOWN:
|
||||
key(VirtualKey.DOWN);
|
||||
break;
|
||||
case SHUFFLE:
|
||||
//
|
||||
break;
|
||||
}
|
||||
} catch (SendCommandException e) {} catch (SendKeyException e) {}
|
||||
}
|
||||
}
|
||||
40
java/src/pm/application/windows/wmp/WMPApplication.java
Normal file
40
java/src/pm/application/windows/wmp/WMPApplication.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package pm.application.windows.wmp;
|
||||
|
||||
import java.util.prefs.Preferences;
|
||||
|
||||
import com.eaio.nativecall.IntCall;
|
||||
|
||||
import pm.Action;
|
||||
import pm.application.windows.Command;
|
||||
import pm.application.windows.WindowsApplication;
|
||||
import pm.exception.application.ApplicationInitialiseException;
|
||||
import pm.exception.application.windows.SendCommandException;
|
||||
|
||||
public class WMPApplication extends WindowsApplication {
|
||||
protected final static String PATH = "C:\\Program Files (x86)\\Windows Media Player\\";
|
||||
protected final static String PROGRAM = "wmplayer.exe";
|
||||
protected final static String NAME = "Windows Media Player";
|
||||
|
||||
public WMPApplication() {
|
||||
super(PATH, PROGRAM, NAME);
|
||||
}
|
||||
|
||||
public void initialise() throws ApplicationInitialiseException {
|
||||
super.initialise();
|
||||
//RegistryKey;
|
||||
}
|
||||
|
||||
public void action(Action action) {
|
||||
System.out.println("WMPApplication: " + action);
|
||||
try {
|
||||
switch (action) {
|
||||
case PLAY:
|
||||
command(Command.MEDIA_PLAY_PAUSE);
|
||||
break;
|
||||
case TEST:
|
||||
command(Command.VOLUME_MUTE);
|
||||
break;
|
||||
}
|
||||
} catch (SendCommandException e) {}
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,9 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
||||
public void initialise() throws DeviceInitialiseException {
|
||||
jit.addHotKeyListener(this);
|
||||
jit.addIntellitypeListener(this);
|
||||
add(
|
||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 'q'),
|
||||
new Task(Action.PLAY, Target.APPLICATIONS));
|
||||
add(
|
||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 'x'),
|
||||
new Task(Action.EXIT, Target.MAIN));
|
||||
@@ -38,7 +41,7 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
||||
add(
|
||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 'r'),
|
||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 's'),
|
||||
new Continuous(Action.REPEAT, Target.APPLICATION, 500));
|
||||
new Continuous(Action.REPEAT, Target.APPLICATIONS, 500));
|
||||
}
|
||||
|
||||
public void onIntellitype(int command) {
|
||||
|
||||
22
java/src/pm/device/player/PlayerDevice.java
Normal file
22
java/src/pm/device/player/PlayerDevice.java
Normal file
@@ -0,0 +1,22 @@
|
||||
package pm.device.player;
|
||||
|
||||
import javazoom.jlgui.player.amp.StandalonePlayer;
|
||||
import pm.Device;
|
||||
import pm.exception.device.DeviceExitException;
|
||||
|
||||
public class PlayerDevice extends Device {
|
||||
StandalonePlayer standalonePlayer;
|
||||
|
||||
public void initialise() {
|
||||
standalonePlayer = new StandalonePlayer();
|
||||
standalonePlayer.loadUI();
|
||||
//standalonePlayer.loadJS();
|
||||
//standalonePlayer.loadPlaylist();
|
||||
//standalonePlayer.
|
||||
System.out.println("niets!");
|
||||
}
|
||||
|
||||
public void exit() throws DeviceExitException {
|
||||
super.exit();
|
||||
}
|
||||
}
|
||||
@@ -9,12 +9,15 @@ import pm.Button;
|
||||
import pm.Device;
|
||||
import pm.Target;
|
||||
import pm.Task;
|
||||
import pm.device.javainput.rumblepad.RumblepadButton;
|
||||
import pm.device.wiimote.gesture.GestureDevice;
|
||||
import pm.exception.device.DeviceInitialiseException;
|
||||
import pm.exception.event.UnknownButtonException;
|
||||
import pm.macro.event.Hold;
|
||||
import pm.macro.event.Press;
|
||||
import pm.macro.event.Release;
|
||||
import pm.task.Continuous;
|
||||
import pm.task.Dynamic;
|
||||
|
||||
import wiiusej.Wiimote;
|
||||
import wiiusej.values.Acceleration;
|
||||
@@ -46,7 +49,7 @@ public class WiimoteDevice extends Device implements GestureListener {
|
||||
public void initialise() throws DeviceInitialiseException {
|
||||
wiimote = wiimoteService.getDevice(this);
|
||||
wiimote.activateMotionSensing();
|
||||
add(
|
||||
/*add(
|
||||
new Hold(WiimoteButton.A),
|
||||
new Task(Action.TRAIN, Target.DEVICE),
|
||||
new Task(Action.STOP, Target.DEVICE));
|
||||
@@ -59,7 +62,37 @@ public class WiimoteDevice extends Device implements GestureListener {
|
||||
add(
|
||||
new Hold(WiimoteButton.HOME),
|
||||
new Task(Action.RECOGNIZE, Target.DEVICE),
|
||||
new Task(Action.STOP, Target.DEVICE));
|
||||
new Task(Action.STOP, Target.DEVICE));*/
|
||||
add(
|
||||
new Press(WiimoteButton.A),
|
||||
new Task(Action.PLAY, Target.APPLICATION));
|
||||
add(
|
||||
new Press(WiimoteButton.B),
|
||||
new Task(Action.MUTE, Target.APPLICATION));
|
||||
add(
|
||||
new Press(WiimoteButton.ONE),
|
||||
new Task(Action.SHUFFLE, Target.APPLICATION));
|
||||
add(
|
||||
new Press(WiimoteButton.TWO),
|
||||
new Task(Action.NEXT, Target.MAIN));
|
||||
add(
|
||||
new Press(WiimoteButton.UP),
|
||||
new Task(Action.NEXT, Target.APPLICATION));
|
||||
add(
|
||||
new Press(WiimoteButton.DOWN),
|
||||
new Task(Action.PREVIOUS, Target.APPLICATION));
|
||||
add(
|
||||
new Hold(WiimoteButton.RIGHT),
|
||||
new Dynamic(Action.FORWARD, Target.APPLICATION, 200, -30));
|
||||
add(
|
||||
new Hold(WiimoteButton.LEFT),
|
||||
new Dynamic(Action.REWIND, Target.APPLICATION, 200, -30));
|
||||
add(
|
||||
new Hold(WiimoteButton.MINUS),
|
||||
new Continuous(Action.VOLUME_DOWN, Target.APPLICATION, 100));
|
||||
add(
|
||||
new Hold(WiimoteButton.PLUS),
|
||||
new Continuous(Action.VOLUME_UP, Target.APPLICATION, 100));
|
||||
}
|
||||
|
||||
public void exit() {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package pm.exception.application.windows;
|
||||
|
||||
public class SendCommandException extends WindowsApplicationException {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package pm.exception.application.windows;
|
||||
|
||||
public class SendKeyException extends WindowsApplicationException {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package pm.exception.application.windows;
|
||||
|
||||
import pm.exception.ApplicationException;
|
||||
|
||||
public class WindowsApplicationException extends ApplicationException {
|
||||
protected static final long serialVersionUID = 1L;
|
||||
}
|
||||
@@ -12,48 +12,45 @@ import pm.application.ApplicationCycle;
|
||||
public class TaskGatherer {
|
||||
protected static ArrayList<TaskListener> taskListenerList;
|
||||
protected static ApplicationCycle applicationCycle;
|
||||
|
||||
|
||||
public static void initialise(ApplicationCycle applicationCycle) {
|
||||
taskListenerList = new ArrayList<TaskListener>();
|
||||
TaskGatherer.applicationCycle = applicationCycle;
|
||||
}
|
||||
|
||||
public static void add(Application application) {
|
||||
add(application);
|
||||
applicationCycle.add(application);
|
||||
public static void add(TaskListener taskListener) {
|
||||
taskListenerList.add(taskListener);
|
||||
}
|
||||
|
||||
public static void add(TaskListener taskListner) {
|
||||
taskListenerList.add(taskListner);
|
||||
}
|
||||
|
||||
|
||||
public static void add(Task task) {
|
||||
if (task instanceof Stopper) {
|
||||
Stopper stopper = (Stopper) task;
|
||||
stopper.stop();
|
||||
} else {
|
||||
Target target = task.getTarget();
|
||||
for (TaskListener taskListener : taskListenerList) {
|
||||
switch (target) {
|
||||
case ALL:
|
||||
taskListener.add(task);
|
||||
case MAIN:
|
||||
if (taskListener instanceof Main) {
|
||||
if (target.equals(Target.APPLICATION)) {
|
||||
applicationCycle.current().add(task);
|
||||
} else {
|
||||
for (TaskListener taskListener : taskListenerList) {
|
||||
switch (target) {
|
||||
case ALL:
|
||||
taskListener.add(task);
|
||||
}
|
||||
break;
|
||||
case DEVICES:
|
||||
if (taskListener instanceof Device) {
|
||||
taskListener.add(task);
|
||||
}
|
||||
break;
|
||||
case APPLICATIONS:
|
||||
if (taskListener instanceof Application) {
|
||||
taskListener.add(task);
|
||||
}
|
||||
break;
|
||||
case APPLICATION:
|
||||
applicationCycle.current().add(task);
|
||||
case MAIN:
|
||||
if (taskListener instanceof Main) {
|
||||
taskListener.add(task);
|
||||
}
|
||||
break;
|
||||
case DEVICES:
|
||||
if (taskListener instanceof Device) {
|
||||
taskListener.add(task);
|
||||
}
|
||||
break;
|
||||
case APPLICATIONS:
|
||||
if (taskListener instanceof Application) {
|
||||
taskListener.add(task);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ public abstract class TaskListener implements Runnable {
|
||||
run = true;
|
||||
while (run) {
|
||||
if (taskQueue.isEmpty()) {
|
||||
sleep(SLEEP);
|
||||
sleep();
|
||||
} else {
|
||||
task(taskQueue.poll());
|
||||
}
|
||||
@@ -48,7 +48,12 @@ public abstract class TaskListener implements Runnable {
|
||||
} catch (InterruptedException e) {}
|
||||
}
|
||||
|
||||
protected void sleep() {
|
||||
sleep(SLEEP);
|
||||
}
|
||||
|
||||
protected void task(Task task) {
|
||||
System.out.println(this);
|
||||
Action action = task.getAction();
|
||||
if (task instanceof Continuous) {
|
||||
Continuous continuous = (Continuous) task;
|
||||
|
||||
25
java/src/pm/util/Native.java
Normal file
25
java/src/pm/util/Native.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package pm.util;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.InputMismatchException;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class Native {
|
||||
public static int getHandle(String name) throws IOException {
|
||||
File file = new File("native/list.exe");
|
||||
Process process = Runtime.getRuntime().exec(file.getPath());
|
||||
Scanner scanner = new Scanner(process.getInputStream());
|
||||
while (scanner.hasNextLine()) {
|
||||
try {
|
||||
int handle = new Integer(scanner.nextLine());
|
||||
String title = scanner.nextLine();
|
||||
if (title.contains(name)) {
|
||||
System.out.println("Window (" + handle + "): \"" + title + "\"");
|
||||
return handle;
|
||||
}
|
||||
} catch (InputMismatchException e) {}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
52
java/src/pm/util/VBScript.java
Normal file
52
java/src/pm/util/VBScript.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package pm.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
|
||||
public class VBScript {
|
||||
public static boolean isRunning(String program) throws IOException {
|
||||
boolean found = false;
|
||||
File file = File.createTempFile("vbsutils", ".vbs");
|
||||
file.deleteOnExit();
|
||||
FileWriter fileWriter = new FileWriter(file);
|
||||
fileWriter.write(String.format(
|
||||
"Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n"
|
||||
+ "Set locator = CreateObject(\"WbemScripting.SWbemLocator\")\n"
|
||||
+ "Set service = locator.ConnectServer()\n"
|
||||
+ "Set processes = service.ExecQuery _\n"
|
||||
+ " (\"select * from Win32_Process where name='%s'\")\n"
|
||||
+ "For Each process in processes\n"
|
||||
+ "wscript.echo process.Name \n"
|
||||
+ "Next\n"
|
||||
+ "Set WSHShell = Nothing\n", program));
|
||||
fileWriter.close();
|
||||
Process process = Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
|
||||
InputStreamReader inputStreamReader = new InputStreamReader(process.getInputStream());
|
||||
BufferedReader input = new BufferedReader(inputStreamReader);
|
||||
String line = input.readLine();
|
||||
found = line != null && line.equals(program);
|
||||
input.close();
|
||||
return found;
|
||||
}
|
||||
|
||||
public static void terminate(String program) throws IOException {
|
||||
File file = File.createTempFile("vbsutils", ".vbs");
|
||||
file.deleteOnExit();
|
||||
FileWriter fileWriter = new FileWriter(file);
|
||||
fileWriter.write(String.format(
|
||||
"Set WshShell = WScript.CreateObject(\"WScript.Shell\")\n"
|
||||
+ "Set locator = CreateObject(\"WbemScripting.SWbemLocator\")\n"
|
||||
+ "Set service = locator.ConnectServer()\n"
|
||||
+ "Set processes = service.ExecQuery _\n"
|
||||
+ " (\"select * from Win32_Process where name='%s'\")\n"
|
||||
+ "For Each process in processes\n"
|
||||
+ "process.Terminate() \n"
|
||||
+ "Next\n"
|
||||
+ "Set WSHShell = Nothing\n", program));
|
||||
fileWriter.close();
|
||||
Runtime.getRuntime().exec("cscript //NoLogo " + file.getPath());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user