From: rnayabed Date: Fri, 19 Feb 2021 23:03:03 +0530 Subject: Added support for windows media keys --- Added support for windows media keys --- --- 'a/DemoCustomNormalAction/DemoCustomNormalAction.iml' +++ b/DemoCustomNormalAction/DemoCustomNormalAction.iml @@ -9,16 +9,16 @@ - - - - + + + + --- 'a/DemoCustomNormalAction/pom.xml' +++ b/DemoCustomNormalAction/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - com.StreamPi + com.stream-pi DemoCustomNormalAction 1.0.0 @@ -37,8 +37,7 @@ - 1.0.0 - 1.0.0 + 1.0.0-SNAPSHOT 16-ea+6 @@ -48,11 +47,6 @@ - - com.stream_pi - util - ${UtilVersion} - org.openjfx @@ -75,8 +69,8 @@ - com.stream_pi - action_api + com.stream-pi + action-api ${ActionAPIVersion} --- 'a/DemoCustomNormalAction/src/main/java/com/stream_pi/democustomnormalaction/DemoCustomNormalAction.java' +++ b/DemoCustomNormalAction/src/main/java/com/stream_pi/democustomnormalaction/DemoCustomNormalAction.java @@ -1,9 +1,9 @@ package com.stream_pi.democustomnormalaction; -import com.stream_pi.actionapi.actionproperty.property.ControlType; -import com.stream_pi.actionapi.actionproperty.property.Property; -import com.stream_pi.actionapi.actionproperty.property.Type; -import com.stream_pi.actionapi.normalaction.NormalAction; +import com.stream_pi.action_api.actionproperty.property.ControlType; +import com.stream_pi.action_api.actionproperty.property.Property; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.action_api.normalaction.NormalAction; import com.stream_pi.util.version.Version; import java.util.ArrayList; --- 'a/DemoCustomNormalAction/src/main/java/module-info.java' +++ b/DemoCustomNormalAction/src/main/java/module-info.java @@ -1,8 +1,5 @@ module com.stream_pi.democustomnormalaction{ - requires com.stream_pi.actionapi; - requires com.stream_pi.util; - + requires com.stream_pi.action_api; requires org.kordamp.ikonli.javafx; - - provides com.stream_pi.actionapi.normalaction.NormalAction with com.stream_pi.democustomnormalaction.DemoCustomNormalAction; + provides com.stream_pi.action_api.normalaction.NormalAction with com.stream_pi.democustomnormalaction.DemoCustomNormalAction; } \ No newline at end of file Binary files 'a/PreBuiltPlugins/hotkeyaction.jar' and b/PreBuiltPlugins/hotkeyaction.jar differ Binary files 'a/PreBuiltPlugins/mediakeyaction.jar' and b/PreBuiltPlugins/mediakeyaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_motheraction.jar' and b/PreBuiltPlugins/obssuite_motheraction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setcurrentprofileaction.jar' and b/PreBuiltPlugins/obssuite_setcurrentprofileaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setcurrentsceneaction.jar' and b/PreBuiltPlugins/obssuite_setcurrentsceneaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setcurrenttransitionaction.jar' and b/PreBuiltPlugins/obssuite_setcurrenttransitionaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setmuteaction.jar' and b/PreBuiltPlugins/obssuite_setmuteaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setpreviewsceneaction.jar' and b/PreBuiltPlugins/obssuite_setpreviewsceneaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setrecordingaction.jar' and b/PreBuiltPlugins/obssuite_setrecordingaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setreplaybufferaction.jar' and b/PreBuiltPlugins/obssuite_setreplaybufferaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setstreamingaction.jar' and b/PreBuiltPlugins/obssuite_setstreamingaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setstudiomodeaction.jar' and b/PreBuiltPlugins/obssuite_setstudiomodeaction.jar differ Binary files 'a/PreBuiltPlugins/obssuite_setvolumeaction.jar' and b/PreBuiltPlugins/obssuite_setvolumeaction.jar differ Binary files 'a/PreBuiltPlugins/playaudioclipaction.jar' and b/PreBuiltPlugins/playaudioclipaction.jar differ Binary files 'a/PreBuiltPlugins/runcommandaction.jar' and b/PreBuiltPlugins/runcommandaction.jar differ Binary files 'a/PreBuiltPlugins/textblockaction.jar' and b/PreBuiltPlugins/textblockaction.jar differ Binary files 'a/PreBuiltPlugins/twitteraction.jar' and b/PreBuiltPlugins/twitteraction.jar differ Binary files 'a/PreBuiltPlugins/websiteaction.jar' and b/PreBuiltPlugins/websiteaction.jar differ --- 'a/hotkeyaction/src/main/java/com/stream_pi/hotkeyaction/HotkeyAction.java' +++ b/hotkeyaction/src/main/java/com/stream_pi/hotkeyaction/HotkeyAction.java @@ -5,6 +5,7 @@ import com.stream_pi.action_api.actionpr import com.stream_pi.action_api.normalaction.NormalAction; import com.stream_pi.util.alert.StreamPiAlert; import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.version.Version; import javafx.application.Platform; @@ -50,8 +51,7 @@ public class HotkeyAction extends Normal if(keyCombination.getStringValue().isBlank()) { - new StreamPiAlert("Hotkey Action", "No key specified", StreamPiAlertType.ERROR).show(); - return; + throw new MinorException("No key specified"); } press(keyCombination.getStringValue() @@ -79,7 +79,8 @@ public class HotkeyAction extends Normal } } - private void releaseCharacters(ArrayList chars) throws InterruptedException { + private void releaseCharacters(ArrayList chars) throws InterruptedException + { for(KeyCode c : chars) { release(c); @@ -87,7 +88,8 @@ public class HotkeyAction extends Normal } } - public KeyCode getKeyCodeValue(String character) { + public KeyCode getKeyCodeValue(String character) throws IllegalArgumentException + { switch (character) { case "A": return A; case "B": return B; --- 'a/mediakeyaction/src/main/java/com/stream_pi/mediakeyaction/MediaKeyAction.java' +++ b/mediakeyaction/src/main/java/com/stream_pi/mediakeyaction/MediaKeyAction.java @@ -5,8 +5,10 @@ import com.stream_pi.action_api.actionpr import com.stream_pi.action_api.normalaction.NormalAction; import com.stream_pi.util.alert.StreamPiAlert; import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.platform.Platform; import com.stream_pi.util.version.Version; +import java.io.*; import java.util.List; public class MediaKeyAction extends NormalAction @@ -37,6 +39,30 @@ public class MediaKeyAction extends Norm @Override public void initAction() throws Exception { + if(getServerConnection().getPlatform() == Platform.WINDOWS) + extractKeyEXEToTmpDirectory(); + } + + private static String absolutePathToExe; + private void extractKeyEXEToTmpDirectory() throws Exception + { + String tmpDirectory = System.getProperty("java.io.tmpdir"); + + InputStream is = getClass().getResource("key.exe").openStream(); + absolutePathToExe = tmpDirectory+"/key.exe"; + File file = new File(absolutePathToExe); + file.deleteOnExit(); + OutputStream os = new FileOutputStream(file); + + byte[] b = new byte[2048]; + int length; + + while ((length = is.read(b)) != -1) { + os.write(b, 0, length); + } + + is.close(); + os.close(); } @Override @@ -46,10 +72,13 @@ public class MediaKeyAction extends Norm switch(getServerConnection().getPlatform()) { - case LINUX : - case LINUX_RPI : + case LINUX : linuxHandler(state); break; + + case WINDOWS: + windowsHandler(state); + break; default: othersHandler(); @@ -57,8 +86,8 @@ public class MediaKeyAction extends Norm } @Override - public void onShutDown() throws Exception { - // TODO Auto-generated method stub + public void onShutDown() throws Exception + { } @@ -95,6 +124,33 @@ public class MediaKeyAction extends Norm } } + private void windowsHandler(int state) throws Exception + { + try + { + switch(state) + { + case 0: runCommand(absolutePathToExe+" 0xB3"); break; + case 1: runCommand(absolutePathToExe+" 0xB1"); break; + case 2: runCommand(absolutePathToExe+" 0xB0"); break; + case 3: runCommand(absolutePathToExe+" 0xAF"); break; + case 4: runCommand(absolutePathToExe+" 0xAE"); break; + case 5: runCommand(absolutePathToExe+" 0xAD"); break; + case 6: runCommand(absolutePathToExe+" 0xB2"); break; + } + } + catch (Exception e) + { + e.printStackTrace(); + + new StreamPiAlert("Uh Oh!", + "Internal Error occured. Check logs, stacktrace. Report to us.", + StreamPiAlertType.ERROR + ).show(); + } + } + + private void othersHandler() { new StreamPiAlert("Uh Oh!", --- /dev/null +++ b/mediakeyaction/src/main/java/com/stream_pi/mediakeyaction/key.c @@ -0,0 +1,61 @@ +// +// key.c - Pauses, then simulates a key press +// +// Written by Ted Burke - last updated 3-9-2014 +// Modified by Debayan Sutradhar (rnayabed) to use multiple keystrokes - 19th February 2021 +// +// To compile with MinGW: +// +// gcc -o keystroke.exe keystroke.c +// +// To run the program: +// +// keystroke.exe +// +// ...then switch to e.g. a Notepad window and wait +// 5 seconds for the A key to be magically pressed. +// + +// Because the SendInput function is only supported in +// Windows 2000 and later, WINVER needs to be set as +// follows so that SendInput gets defined when windows.h +// is included below. + +#define WINVER 0x0500 +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ + // This structure will be used to create the keyboard + // input event. + INPUT ip; + + // Pause for 5 seconds. + //Sleep(5000); + + // Set up a generic keyboard event. + ip.type = INPUT_KEYBOARD; + ip.ki.wScan = 0;// DirectInput key scancode for the "A" key + ip.ki.time = 0; + ip.ki.dwExtraInfo = 0; + + // read a hex string and turn it into a value + //virtual key code + int vkc; + sscanf(argv[1], "%x", &vkc); + + // Press the key (using scancode to specify which key) + ip.ki.wVk = vkc; + ip.ki.dwFlags = 0; + SendInput(1, &ip, sizeof(INPUT)); + + // Release the key (again, using scancode to specify which key) + ip.ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_SCANCODE; + SendInput(1, &ip, sizeof(INPUT)); + + // Exit normally + return 0; +} \ No newline at end of file Binary files /dev/null and b/mediakeyaction/src/main/resources/com/stream_pi/mediakeyaction/key.exe differ --- 'a/obssuite/mother/OBSSuite-MotherAction.iml' +++ b/obssuite/mother/OBSSuite-MotherAction.iml @@ -10,15 +10,15 @@ - - - - - - - - + + + + + + + + --- 'a/obssuite/mother/pom.xml' +++ b/obssuite/mother/pom.xml @@ -64,7 +64,6 @@ net.twasi obs-websocket-java ${OBSWebsocketJavaVersion} - --- 'a/obssuite/mother/src/main/java/module-info.java' +++ b/obssuite/mother/src/main/java/module-info.java @@ -13,7 +13,6 @@ module com.stream_pi.obssuite.motheracti requires transitive org.eclipse.jetty.io; requires transitive com.google.gson; - exports mother.motherconnection; provides com.stream_pi.action_api.normalaction.NormalAction with mother.Mother; --- 'a/obssuite/setvolume/.gitignore' +++ b/obssuite/setvolume/.gitignore @@ -1,6 +1,6 @@ .idea/ target/ - +OBSSuite-SetVolumeAction.iml .classpath .factorypath .project --- 'a/obssuite/setvolume/OBSSuite-SetVolumeAction.iml' +++ b/obssuite/setvolume/OBSSuite-SetVolumeAction.iml @@ -9,18 +9,18 @@ - + + + - - - - + +