This commit is contained in:
@@ -40,13 +40,13 @@ public class Main extends TaskListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void initialise() throws DeviceInitialiseException {
|
public void initialise() throws DeviceInitialiseException {
|
||||||
//add(new JIntellitypeDevice());
|
add(new JIntellitypeDevice());
|
||||||
//add(new PlayerDevice());
|
//add(new PlayerDevice());
|
||||||
//add(new RumblepadDevice());
|
//add(new RumblepadDevice());
|
||||||
//add(new WiimoteDevice());
|
//add(new WiimoteDevice());
|
||||||
//add(new GUIDevice());
|
//add(new GUIDevice());
|
||||||
//add(new TextDevice());
|
//add(new TextDevice());
|
||||||
add(new LanTextDevice());
|
//add(new LanTextDevice());
|
||||||
for (Device device : deviceList) {
|
for (Device device : deviceList) {
|
||||||
try {
|
try {
|
||||||
device.initialise();
|
device.initialise();
|
||||||
@@ -57,7 +57,7 @@ public class Main extends TaskListener {
|
|||||||
|
|
||||||
add(new ExampleApplication());
|
add(new ExampleApplication());
|
||||||
//add(new WMPApplication());
|
//add(new WMPApplication());
|
||||||
//add(new GomPlayerApplication());
|
add(new GomPlayerApplication());
|
||||||
//add(new WinampApplication());
|
//add(new WinampApplication());
|
||||||
//add(new iTunesApplication());
|
//add(new iTunesApplication());
|
||||||
for (Application application : applicationCycle) {
|
for (Application application : applicationCycle) {
|
||||||
@@ -95,6 +95,7 @@ public class Main extends TaskListener {
|
|||||||
break;
|
break;
|
||||||
case PREVIOUS:
|
case PREVIOUS:
|
||||||
applicationCycle.previous();
|
applicationCycle.previous();
|
||||||
|
System.out.println(applicationCycle.current());
|
||||||
break;
|
break;
|
||||||
case EXIT:
|
case EXIT:
|
||||||
exit();
|
exit();
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ abstract public class WindowsApplication extends Application {
|
|||||||
protected final static int TERMINATE_SLEEP = 500;
|
protected final static int TERMINATE_SLEEP = 500;
|
||||||
protected final static int START_SLEEP = 500;
|
protected final static int START_SLEEP = 500;
|
||||||
|
|
||||||
|
protected final static int WM_COMMAND = 0x0111;
|
||||||
protected final static int WM_APPCOMMAND = 0x0319;
|
protected final static int WM_APPCOMMAND = 0x0319;
|
||||||
|
|
||||||
protected String program;
|
protected String program;
|
||||||
@@ -25,6 +26,7 @@ abstract public class WindowsApplication extends Application {
|
|||||||
|
|
||||||
protected Process process;
|
protected Process process;
|
||||||
protected int handle;
|
protected int handle;
|
||||||
|
|
||||||
protected IntCall sendMessage;
|
protected IntCall sendMessage;
|
||||||
protected IntCall postMessage;
|
protected IntCall postMessage;
|
||||||
protected IntCall mapVirtualKey;
|
protected IntCall mapVirtualKey;
|
||||||
@@ -87,10 +89,18 @@ abstract public class WindowsApplication extends Application {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void command(int command) throws SendCommandException {
|
||||||
|
int result = sendMessage.executeCall(new Object[] {
|
||||||
|
handle, WM_COMMAND, command});
|
||||||
|
if (result < 1 || sendMessage.getLastError() != null) {
|
||||||
|
throw new SendCommandException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
protected void key(Type key, int code) throws SendKeyException {
|
protected void key(Type key, int code) throws SendKeyException {
|
||||||
int scanCode = mapVirtualKey.executeCall(new Object[] {code, 0});
|
int scanCode = mapVirtualKey.executeCall(new Object[] {code, 0});
|
||||||
int result = postMessage.executeCall(new Object[] {
|
int result = postMessage.executeCall(new Object[] {
|
||||||
handle, key.getCode(), code, scanCode << 16});
|
handle, key.getCode(), code, 1 | (scanCode << 16)});
|
||||||
if (result < 1 || postMessage.getLastError() != null) {
|
if (result < 1 || postMessage.getLastError() != null) {
|
||||||
throw new SendKeyException();
|
throw new SendKeyException();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ public class GomPlayerApplication extends WindowsApplication {
|
|||||||
protected final static String NAME = "GOM Player";
|
protected final static String NAME = "GOM Player";
|
||||||
|
|
||||||
public GomPlayerApplication() {
|
public GomPlayerApplication() {
|
||||||
super(PROGRAM, NAME, "C:\\Program Files (x86)\\GomPlayer\\GOM.exe");
|
super(PROGRAM, NAME, "C:\\Program Files (x86)\\GRETECH\\GomPlayer\\GOM.exe");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void action(Action action) {
|
public void action(Action action) {
|
||||||
@@ -23,7 +23,8 @@ public class GomPlayerApplication extends WindowsApplication {
|
|||||||
try {
|
try {
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case PLAY:
|
case PLAY:
|
||||||
key(Type.DOWN, Key.SPACE);
|
System.out.println("spacie " + handle);
|
||||||
|
command(0x800C);
|
||||||
break;
|
break;
|
||||||
case NEXT:
|
case NEXT:
|
||||||
command(Command.MEDIA_NEXTTRACK);
|
command(Command.MEDIA_NEXTTRACK);
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
import com.melloware.jintellitype.JIntellitype;
|
import com.melloware.jintellitype.JIntellitype;
|
||||||
|
|
||||||
|
import pm.application.windows.Key;
|
||||||
import pm.macro.event.Press;
|
import pm.macro.event.Press;
|
||||||
|
|
||||||
public class Hotkey extends Press {
|
public class Hotkey extends Press {
|
||||||
@@ -13,23 +14,27 @@ public class Hotkey extends Press {
|
|||||||
public Hotkey(int modifier, int keycode) {
|
public Hotkey(int modifier, int keycode) {
|
||||||
super(null); // Todo: nettere oplossing zoeken / controleren op null
|
super(null); // Todo: nettere oplossing zoeken / controleren op null
|
||||||
int id = hotkeyList.size();
|
int id = hotkeyList.size();
|
||||||
button = new HotkeyButton(id);
|
button = new Modifier(id);
|
||||||
jit.registerHotKey(id, modifier, keycode);
|
jit.registerHotKey(id, modifier, keycode);
|
||||||
hotkeyList.add(this);
|
hotkeyList.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hotkey(int modifier, char key) {
|
public Hotkey(int modifier, char character) {
|
||||||
this(modifier, (int) Character.toUpperCase(key));
|
this(modifier, (int) Character.toUpperCase(character));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hotkey(char key) {
|
public Hotkey(char character) {
|
||||||
this(0, (int) Character.toUpperCase(key));
|
this(0, (int) Character.toUpperCase(character));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Hotkey(int keycode) {
|
public Hotkey(int keycode) {
|
||||||
this(0, keycode);
|
this(0, keycode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Hotkey(Key key) {
|
||||||
|
this(key.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
public static void initialise(ArrayList<Hotkey> actionList, JIntellitype jit) {
|
public static void initialise(ArrayList<Hotkey> actionList, JIntellitype jit) {
|
||||||
Hotkey.hotkeyList = actionList;
|
Hotkey.hotkeyList = actionList;
|
||||||
Hotkey.jit = jit;
|
Hotkey.jit = jit;
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import pm.Action;
|
|||||||
import pm.Device;
|
import pm.Device;
|
||||||
import pm.Target;
|
import pm.Target;
|
||||||
import pm.Task;
|
import pm.Task;
|
||||||
|
import pm.application.windows.Key;
|
||||||
import pm.exception.EventException;
|
import pm.exception.EventException;
|
||||||
import pm.exception.device.DeviceInitialiseException;
|
import pm.exception.device.DeviceInitialiseException;
|
||||||
import pm.macro.event.Press;
|
import pm.macro.event.Press;
|
||||||
@@ -30,17 +31,23 @@ public class JIntellitypeDevice extends Device implements HotkeyListener, Intell
|
|||||||
jit.addHotKeyListener(this);
|
jit.addHotKeyListener(this);
|
||||||
jit.addIntellitypeListener(this);
|
jit.addIntellitypeListener(this);
|
||||||
add(
|
add(
|
||||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 'q'),
|
new Hotkey(Key.PRIOR),
|
||||||
|
new Task(Action.PREVIOUS, Target.MAIN));
|
||||||
|
add(
|
||||||
|
new Hotkey(Key.NEXT),
|
||||||
|
new Task(Action.NEXT, Target.MAIN));
|
||||||
|
add(
|
||||||
|
new Hotkey(Modifier.CTRL | Modifier.WIN, 'q'),
|
||||||
new Task(Action.PLAY, Target.APPLICATIONS));
|
new Task(Action.PLAY, Target.APPLICATIONS));
|
||||||
add(
|
add(
|
||||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 'x'),
|
new Hotkey(Modifier.CTRL | Modifier.WIN, 'x'),
|
||||||
new Task(Action.EXIT, Target.MAIN));
|
new Task(Action.EXIT, Target.MAIN));
|
||||||
add(
|
add(
|
||||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 't'),
|
new Hotkey(Modifier.CTRL | Modifier.WIN, 't'),
|
||||||
new Task(Action.TEST, Target.MAIN));
|
new Task(Action.TEST, Target.MAIN));
|
||||||
add(
|
add(
|
||||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 'r'),
|
new Hotkey(Modifier.CTRL | Modifier.WIN, 'r'),
|
||||||
new Hotkey(HotkeyButton.CTRL | HotkeyButton.WIN, 's'),
|
new Hotkey(Modifier.CTRL | Modifier.WIN, 's'),
|
||||||
new Continuous(Action.REPEAT, Target.APPLICATIONS, 500));
|
new Continuous(Action.REPEAT, Target.APPLICATIONS, 500));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import com.melloware.jintellitype.JIntellitype;
|
|||||||
|
|
||||||
import pm.Button;
|
import pm.Button;
|
||||||
|
|
||||||
public class HotkeyButton implements Button {
|
public class Modifier implements Button {
|
||||||
public static final int
|
public static final int
|
||||||
ALT = JIntellitype.MOD_ALT,
|
ALT = JIntellitype.MOD_ALT,
|
||||||
CTRL = JIntellitype.MOD_CONTROL,
|
CTRL = JIntellitype.MOD_CONTROL,
|
||||||
@@ -13,7 +13,7 @@ public class HotkeyButton implements Button {
|
|||||||
|
|
||||||
protected int code;
|
protected int code;
|
||||||
|
|
||||||
protected HotkeyButton(int code) {
|
protected Modifier(int code) {
|
||||||
this.code = code;
|
this.code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user