From 64d6c2eeca88d0a349d7944f05ce357f0c66c35a Mon Sep 17 00:00:00 2001 From: Saif Alaqqad Date: Mon, 12 Feb 2024 19:31:02 +0300 Subject: [PATCH] Add support for string RecallPreset command + Update README --- README.md | 20 ++++++++++---------- examples/README.md | 1 - src/VMRCommands.ahk | 9 ++++++--- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index fc24343..f51d2f4 100644 --- a/README.md +++ b/README.md @@ -9,32 +9,32 @@ VMR.ahk To use `VMR.ahk` in your script, follow one of the following methods: -### A - ahkpm installation +### A. ahkpm installation -1. Install and set up [ahkpm](https://github.com/joshuacc/ahkpm), then run `ahkpm install gh:SaifAqqad/VMR.ahk` -2. Run `ahkpm include gh:SaifAqqad/VMR.ahk -f my-script.ahk` to add an include directive in your script - ###### Replace *my-script.ahk* with your script's path +1. Install and set up [ahkpm](https://github.com/joshuacc/ahkpm) +2. Run `ahkpm install gh:SaifAqqad/VMR.ahk` +3. Include VMR in your script by running `ahkpm include gh:SaifAqqad/VMR.ahk -f myScript.ahk` + ###### Replace *myScript.ahk* with your script's path -### B - Manual Installation +### B. Manual Installation 1. Download the latest pre-built version from the [`dist` folder](https://raw.githubusercontent.com/SaifAqqad/VMR.ahk/master/dist/VMR.ahk) or follow the build instructions below 2. Include it using `#Include VMR.ahk` or copy it to a [library folder](https://www.autohotkey.com/docs/v2/Scripts.htm#lib) and use `#Include ` -**Note: The current version of VMR only works with AHK v2, The AHK v1 version is available on the [v1 branch](https://github.com/SaifAqqad/VMR.ahk/tree/v1)** +> [!IMPORTANT] +> The current version of VMR ***only*** supports AHK v2, The AHK v1 version is still available on the [v1 branch](https://github.com/SaifAqqad/VMR.ahk/tree/v1) but will not receive any updates. ## Usage - - Create an instance of the VMR class and log in to the API: ```ahk voicemeeter := VMR().login() ``` -- The `VMR` object will have two arrays (`Bus` and `Strip`), as well as other objects, that will allow you to control voicemeeter in AHK. +- The `VMR` object will have two arrays (`Bus` and `Strip`), as well as other properties/methods that will allow you to control voicemeeter in AHK ```ahk voicemeeter.Bus[1].mute := true voicemeeter.Strip[4].gain++ ``` - - ##### For more info, check out the [documentation](https://saifaqqad.github.io/VMR.ahk/) + ##### For more info, check out the [documentation](https://saifaqqad.github.io/VMR.ahk/) and the [examples](./examples/) ## Build instructions diff --git a/examples/README.md b/examples/README.md index 252a48f..4503045 100644 --- a/examples/README.md +++ b/examples/README.md @@ -3,7 +3,6 @@ * ### [Hotkey example](./hotkey_example.ahk): create hotkeys to control VoiceMeeter. * ### [UI example](./ui_example.ahk): a simple GUI that controls VoiceMeeter's buses - ###### Not converted to v2 yet ![UI example](https://user-images.githubusercontent.com/47293197/118356850-d7be9e80-b57f-11eb-843a-db7f8dd996d1.gif) * ### [Level stabilizer](./level_stabilizer_example.ahk): stabilizes the audio level by adjusting the gain. diff --git a/src/VMRCommands.ahk b/src/VMRCommands.ahk index 9384115..2d9ad74 100644 --- a/src/VMRCommands.ahk +++ b/src/VMRCommands.ahk @@ -147,11 +147,14 @@ class VMRCommands { /** * Recalls a Preset Scene * - * @param {Number} p_presetIndex - The one-based index of the preset + * @param {String | Number} p_preset - The name of the preset to recall or its one-based index * __________ * @returns {Boolean} - true if the command was successful */ - RecallPreset(p_presetIndex) { - return VBVMR.SetParameterFloat("Command", "Preset[" p_presetIndex - 1 "].Recall", 1) == 0 + RecallPreset(p_preset) { + if(IsNumber(p_preset)) + return VBVMR.SetParameterFloat("Command", "Preset[" p_preset - 1 "].Recall", 1) == 0 + else + return VBVMR.SetParameterString("Command", "RecallPreset", p_preset) == 0 } }