diff --git a/.gitignore b/.gitignore index deb9af1..0ba4f43 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ +/.vs *.bak -*.ini +MidiToMacro.ini +/SOURCE \ No newline at end of file diff --git a/GetSteamGamesList.sh b/GetSteamGamesList.sh new file mode 100644 index 0000000..c4ba577 --- /dev/null +++ b/GetSteamGamesList.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +# Define the Steam library path (use double backslashes for Windows paths) +STEAM_LIBRARY_PATH="D:\\SteamLibrary\\steamapps\\common" + +# Define the output file +OUTPUT_FILE="game_exe_list.txt" + +# Clear the output file if it exists +> "$OUTPUT_FILE" + +# Loop through each game directory +for game_dir in "$STEAM_LIBRARY_PATH"/*; do + if [ -d "$game_dir" ]; then + # Find all .exe files (case-insensitive) and print only the filenames exactly as they appear + find "$game_dir" -type f -iname "*.exe" -exec basename {} \; >> "$OUTPUT_FILE" + fi +done + +echo "Game executable list saved to $OUTPUT_FILE" diff --git a/MidiRules.ahk b/MidiRules.ahk index cd8549d..7bf4bff 100644 --- a/MidiRules.ahk +++ b/MidiRules.ahk @@ -13,36 +13,50 @@ ProcessNote(device, channel, note, velocity, isNoteOn) { } ProcessCC(device, channel, cc, value) { - if (cc = 21 or cc = 29) { - scaled_value := ConvertCCValueToScale(value, 0, 127) - vol := scaled_value * 100 - SoundSet, vol + + ;************************************************* + ;* Rotary Knob 1 (Master Volume Control) * + ;************************************************* + + if (cc = 21) { + scaled_value := ConvertCCValueToScale(value, 7, 120) + vol := Round(scaled_value * 100) ; Scale to percentage + SoundSet, vol, MASTER + ; Minimizing feedback to optimize speed DisplayOutput("Volume", vol) - } else if (cc = 51) { - Send {Volume_Mute} - DisplayOutput("Volume", "Mute") - } else if (cc = 52 and value != 0) { - Send {Volume_Down} - DisplayOutput("Volume", "Down") - } else if (cc = 53 and value != 0) { - Send {Volume_Up} - DisplayOutput("Volume", "Up") - } else if (cc = 54 and value != 0) { - Send {Media_Play_Pause} - DisplayOutput("Media", "Play/Pause") - } else if (cc = 55 and value != 0) { - Send {Media_Stop} - DisplayOutput("Media", "Stop") - } else if (cc = 56 and value != 0) { - Send {Media_Prev} - DisplayOutput("Media", "Previous") - } else if (cc = 57 and value != 0) { - Send {Media_Next} - DisplayOutput("Media", "Next") - } else if (cc = 58 and value != 0) { - ; Place a cue marker in Sound Forge 9 - ControlSend, , {Alt down}m{Alt up}, ahk_class #32770 - DisplayOutput("Sound Forge", "Place Cue Marker") + } + + if (cc = 0 and value = 1) { + SoundSet, 1, MASTER, MUTE ; Unmute + DisplayOutput("Volume Unmuted", "") + } else if (cc = 0 and value = 0) { + SoundSet, 0, MASTER, MUTE ; Mute + DisplayOutput("Volume Muted", "") + } + + ;************************************************* + ;* Rotary Knob 2 (Mozilla Firefox Volume Control)* + ;************************************************* + + if (cc = 22) { + scaled_value := ConvertCCValueToScale(value, 7, 120) + vol := Round(scaled_value, 2) ; Scale to the range used by nircmd + ; Adjust Firefox volume using nircmd + Run, nircmd setappvolume firefox.exe %vol% + ; Minimizing feedback to optimize speed + scaled_value := ConvertCCValueToScale(vol, 0, 127) + percentage := Round(vol * 100) ; Scale to percentage + DisplayOutput("Firefox Volume", percentage) + } + + if (cc = 1 and value = 1) { + ; Mute Mozilla Firefox + Run, nircmd muteappvolume firefox.exe 1 + DisplayOutput("Firefox Muted", "") + } else if (cc = 1 and value = 0) { + ; Unmute Mozilla Firefox + Run, nircmd muteappvolume firefox.exe 0 + DisplayOutput("Firefox Unmuted", "") } } diff --git a/NirCmd.chm b/NirCmd.chm new file mode 100644 index 0000000..52af31f Binary files /dev/null and b/NirCmd.chm differ diff --git a/Original_README.md b/Original_README.md new file mode 100644 index 0000000..bcb0a6c --- /dev/null +++ b/Original_README.md @@ -0,0 +1,89 @@ +# MidiToMacro + +This is an AutoHotKey script for Windows, to map MIDI input values to hotkeys or macros. + +You can use this script to bind CC messages to media keys (play/pause/next), volume sliders, or unusual keyboard combinations (ctrl+shift+alt+F13) which you can assign in programs like StreamLabs OBS. + +It's cobbled together from scripts found on the AHK forums. It originally supported mapping MIDI inputs to a virtual joystick using vJoy, and to MIDI outputs; this functionality has been removed. All credit goes to the original authors. + +## Running + +Double click on `MidiToMacro.ahk`. + +To launch the program when Windows starts, you can add a shortcut to the file in your Start Menu\Startup folder. + +The first time you launch the script, you will be prompted to choose a MIDI input device. If you need to change it later, you can right click on the system tray icon and click `MidiSet`. Or, you can open the `MidiMon`, and change the input in the "Midi Input" dropdown menu; the script will automatically reload. + +To see a log of recent MIDI input messages and any output events, right click on the system tray icon and click `MidiMon`. You can close this window, and the script will keep running in the background. + +## Adding rules + +You can add rules to the file `MidiRules.ahk`. + +There are four handler functions you can modify: + +- `ProcessNote`: handles note on/off events +- `ProcessCC`: handles CC (Control Change, or Continuous Control) events +- `ProcessPC`: handles patch change events +- `ProcessPitchBend`: handle pitch bend events + +Within each function, you can have a series of `if/else` blocks. + +``` +if (cc = 21) { + ; ... +} else if (cc = 51) { + ; ... +} else if (cc = 52 and value != 0) { + ; ... +} +``` + +A rule to toggle the mute button when receiving CC 51 might look like this: + +``` +if (cc = 51) { + Send {Volume_Mute} + DisplayOutput("Volume", "Mute") +} +``` + +`Send {Volume_Mute}` simulates pressing the "mute" button on your keyboard. `DisplayOutput("Volume", "Mute")` logs a message to the MidiMon GUI. + +A rule to press the play/pause button might look like this: + +``` +if (cc = 54 and value != 0) { + Send {Media_Play_Pause} + DisplayOutput("Media", "Play/Pause") +} +``` + +`value != 0` lets us detect button presses, and ignores button releases, on our MIDI controller. (Without this clause, we'd send the keyboard macro twice; once for the button press, and agin for the button release.) + +Here's a rule to map a continuous control from a slider to the main Windows mixer volume: + +``` +if (cc = 21 or cc = 29) { + scaled_value := ConvertCCValueToScale(value, 0, 127) + vol := scaled_value * 100 + SoundSet, vol + DisplayOutput("Volume", vol) +} +``` + +`ConvertCCValueToScale` is a utility function from `CommonFunctions.ahk`. It converts a value within a give range into a floating point number between 0 and 1. + +Here's a rule to trigger a keyboard shortcut in a specific application; in this example, Sound Forge 9: + +``` +if (cc = 58 and value != 0) { + ; Place a cue marker in Sound Forge 9 + ControlSend, , {Alt down}m{Alt up}, ahk_class #32770 + DisplayOutput("Sound Forge", "Place Cue Marker") +} +``` + +You can use AutoHotKey's "WindowSpy" script to identify windows, or controls within an application, for use with `ahk_class`. + +You can find [a list of standard CC messages online](https://www.midi.org/specifications-old/item/table-3-control-change-messages-data-bytes-2). You could use any control number without a specified control function, including numbers between 20-31, 52-63, and 102-119. But, any control number should work fine. diff --git a/Untitled.png b/Untitled.png new file mode 100644 index 0000000..8d95591 Binary files /dev/null and b/Untitled.png differ diff --git a/game_exe_list.txt b/game_exe_list.txt new file mode 100644 index 0000000..3ff013d --- /dev/null +++ b/game_exe_list.txt @@ -0,0 +1,153 @@ +BatmanAK.exe +pbsvc.exe +Cities.exe +dowser.exe +mono.exe +al.exe +booc.exe +csharp.exe +gacutil.exe +gmcs.exe +httpcfg.exe +ilasm.exe +installutil.exe +lc.exe +mconfig.exe +mdoc.exe +mkbundle.exe +mono-api-info.exe +mono-service.exe +mono-shlib-cop.exe +mono-xmltool.exe +monolinker.exe +monop.exe +nunit-console.exe +pdb2mdb.exe +RabbitMQ.Client.Apigen.exe +resgen.exe +sgen.exe +sqlmetal.exe +sqlsharp.exe +svcutil.exe +us.exe +wsdl.exe +xbuild.exe +xsd.exe +booc.exe +smcs.exe +us.exe +booc.exe +smcs.exe +us.exe +Dungeon Alchemist.exe +ffmpeg.exe +UnityCrashHandler64.exe +f1_res_Config.exe +f1_res_patcher.exe +Fallout1_High_Resolution_Patch_4.1.8.exe +FalloutLauncher.exe +FALLOUTW.EXE +falloutwHR.exe +f2_res_Config.exe +f2_res_patcher.exe +fallout2.exe +fallout2HR.exe +Fallout2Launcher.exe +Fallout2_High_Resolution_Patch_4.1.8.exe +FalloutClient.exe +FalloutNV.exe +FalloutNVLauncher.exe +FalloutNV_backup.exe +FNVpatch.exe +nvse_loader.exe +DXSETUP.exe +vcredist_x86.exe +crs-handler.exe +helldivers2.exe +GGSetup.exe +gguninst.exe +ffmpeg.exe +ffprobe.exe +krita.exe +kritarunner.exe +CrashReportClient.exe +EpicWebHelper.exe +Palworld-Win64-Shipping.exe +Palworld.exe +BEService_x64.exe +CrashUploader.exe +LaunchPad.exe +GameLauncherCefChildProcess.exe +wws_crashreport_uploader.exe +PlanetSide2_x64.exe +PlanetSide2_x64_BE.exe +Uninstaller.exe +wws_crashreport_uploader.exe +jabswitch.exe +jaccessinspector-32.exe +jaccessinspector.exe +jaccesswalker-32.exe +jaccesswalker.exe +java.exe +javaw.exe +jfr.exe +jrunscript.exe +keytool.exe +kinit.exe +klist.exe +ktab.exe +rmiregistry.exe +jabswitch.exe +jaccessinspector.exe +jaccesswalker.exe +java.exe +javaw.exe +jfr.exe +jrunscript.exe +keytool.exe +kinit.exe +klist.exe +ktab.exe +rmiregistry.exe +ProjectZomboid32.exe +ProjectZomboid64.exe +mist.exe +retroarch.exe +RCT.EXE +Autorun.exe +ddhelp.exe +dplaysvr.exe +dxinfo.exe +dxsetup.exe +dxtool.exe +AcroReader51_ENU.exe +setup.exe +SkullGirls.exe +AutoReporter.exe +FlashInstallWrapper.exe +flashplayer_10_3r183_90_win.exe +ProxyInstallShield.exe +SetupPatcherFix.exe +UE3Redist_vs2010.exe +UE3Redist_vs2012.exe +CoherentUI_Host.exe +ShippingPC-BattleGame.exe +SmiteEAC.exe +CoherentUI_Host.exe +ShippingPC-BattleGame.exe +Smite.exe +SmiteEAC.exe +EasyAntiCheat_EOS_Setup.exe +SmiteBootstrapper.exe +SmiteEAC64.exe +Launcher.exe +DXSETUP.exe +sonic2app.exe +Typefighters.exe +DAEMON.exe +UnityCrashHandler64.exe +UnityCrashHandler64.exe +WhosLila.exe +YourOnlyMoveIsHUSTLE.exe +masterduel.exe +UnityCrashHandler64.exe diff --git a/nircmd.exe b/nircmd.exe new file mode 100644 index 0000000..5d575ff Binary files /dev/null and b/nircmd.exe differ diff --git a/nircmdc.exe b/nircmdc.exe new file mode 100644 index 0000000..847c69a Binary files /dev/null and b/nircmdc.exe differ