From 30d2880cbfdbaffd4cc09f27ea4ea225571ec258 Mon Sep 17 00:00:00 2001 From: MatejGolian <11446675+MatejGolian@users.noreply.github.com> Date: Thu, 17 Oct 2024 16:09:57 +0200 Subject: [PATCH 1/2] Begin implementing Kontakt instrument switching --- CHANGELOG.md | 1 + Includes/Overlays/Kontakt7.ahk | 47 ++++++++++++++++++++++++++++++++++ Includes/Overlays/Kontakt8.ahk | 47 ++++++++++++++++++++++++++++++++++ README.md | 3 ++- 4 files changed, 97 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 71c5ba5..4272577 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added option to disable the 'window may be covered' warning - Added Kontakt 8 support +- Added Kontakt instrument switching ### Changed diff --git a/Includes/Overlays/Kontakt7.ahk b/Includes/Overlays/Kontakt7.ahk index 8ee9e16..5bbf5af 100644 --- a/Includes/Overlays/Kontakt7.ahk +++ b/Includes/Overlays/Kontakt7.ahk @@ -14,6 +14,8 @@ Class Kontakt7 { PluginHeader.AddCustomButton("LIBRARY On/Off",,, Kontakt7.ActivatePluginHeaderButton).SetHotkey("!L", "Alt+L") PluginHeader.AddCustomButton("VIEW menu",,, Kontakt7.ActivatePluginHeaderButton).SetHotkey("!V", "Alt+V") PluginHeader.AddCustomButton("SHOP (Opens in default web browser)",,, Kontakt7.ActivatePluginHeaderButton).SetHotkey("!S", "Alt+S") + PluginHeader.AddCustomButton("Previous instrument", Kontakt7.MoveToPluginInstrumentButton,,, Kontakt7.ActivatePluginInstrumentButton).SetHotkey("^P", "Ctrl+P") + PluginHeader.AddCustomButton("Next instrument", Kontakt7.MoveToPluginInstrumentButton,,, Kontakt7.ActivatePluginInstrumentButton).SetHotkey("^N", "Ctrl+N") PluginHeader.AddCustomButton("Snapshot menu", Kontakt7.MoveToPluginSnapshotButton,,, Kontakt7.ActivatePluginSnapshotButton).SetHotkey("!M", "Alt+M") PluginHeader.AddCustomButton("Previous snapshot", Kontakt7.MoveToPluginSnapshotButton,,, Kontakt7.ActivatePluginSnapshotButton).SetHotkey("!P", "Alt+P") PluginHeader.AddCustomButton("Next snapshot", Kontakt7.MoveToPluginSnapshotButton,,, Kontakt7.ActivatePluginSnapshotButton).SetHotkey("!N", "Alt+N") @@ -194,6 +196,32 @@ Class Kontakt7 { } } + Class ActivatePluginInstrumentButton { + Static Call(InstrumentButton) { + Critical + UIAElement := GetUIAElement("15,1,5") + If Not UIAElement = False And UIAElement.Name = "SHOP" { + Try + ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A" + Catch + Return + Kontakt7.MoveToPluginInstrumentButton("Previous instrument") + If CheckColor() { + Kontakt7.MoveToPluginInstrumentButton(InstrumentButton) + Click + Return + } + } + AccessibilityOverlay.Speak("Instrument switching unavailable. Make sure that an instrument is loaded and that you're in rack view.") + CheckColor() { + MouseGetPos &mouseXPosition, &mouseYPosition + If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454" + Return True + Return False + } + } + } + Class ActivatePluginSnapshotButton { Static Call(SnapshotButton) { Critical @@ -261,6 +289,25 @@ Class Kontakt7 { } } + Class MoveToPluginInstrumentButton { + Static Call(InstrumentButton) { + Label := InstrumentButton + If InstrumentButton Is Object + Label := InstrumentButton.Label + UIAElement := GetUIAElement("15,1,5") + If Not UIAElement = False And UIAElement.Name = "SHOP" { + Try + ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A" + Catch + Return + If Label = "Previous instrument" + MouseMove ControlX + ControlWidth - 352, ControlY + 88 + Else + MouseMove ControlX + ControlWidth - 332, ControlY + 88 + } + } + } + Class MoveToPluginSnapshotButton { Static Call(SnapshotButton) { If SnapshotButton Is Object And InStr(SnapshotButton.Label, "Snapshot", True) diff --git a/Includes/Overlays/Kontakt8.ahk b/Includes/Overlays/Kontakt8.ahk index 3c346d8..db7360a 100644 --- a/Includes/Overlays/Kontakt8.ahk +++ b/Includes/Overlays/Kontakt8.ahk @@ -14,6 +14,8 @@ Class Kontakt8 { PluginHeader.AddCustomButton("LIBRARY On/Off",,, Kontakt8.ActivatePluginHeaderButton).SetHotkey("!L", "Alt+L") PluginHeader.AddCustomButton("VIEW menu",,, Kontakt8.ActivatePluginHeaderButton).SetHotkey("!V", "Alt+V") PluginHeader.AddCustomButton("SHOP (Opens in default web browser)",,, Kontakt8.ActivatePluginHeaderButton).SetHotkey("!S", "Alt+S") + PluginHeader.AddCustomButton("Previous instrument", Kontakt8.MoveToPluginInstrumentButton,,, Kontakt8.ActivatePluginInstrumentButton).SetHotkey("^P", "Ctrl+P") + PluginHeader.AddCustomButton("Next instrument", Kontakt8.MoveToPluginInstrumentButton,,, Kontakt8.ActivatePluginInstrumentButton).SetHotkey("^N", "Ctrl+N") PluginHeader.AddCustomButton("Snapshot menu", Kontakt8.MoveToPluginSnapshotButton,,, Kontakt8.ActivatePluginSnapshotButton).SetHotkey("!M", "Alt+M") PluginHeader.AddCustomButton("Previous snapshot", Kontakt8.MoveToPluginSnapshotButton,,, Kontakt8.ActivatePluginSnapshotButton).SetHotkey("!P", "Alt+P") PluginHeader.AddCustomButton("Next snapshot", Kontakt8.MoveToPluginSnapshotButton,,, Kontakt8.ActivatePluginSnapshotButton).SetHotkey("!N", "Alt+N") @@ -194,6 +196,32 @@ Class Kontakt8 { } } + Class ActivatePluginInstrumentButton { + Static Call(InstrumentButton) { + Critical + UIAElement := GetUIAElement("15,1,5") + If Not UIAElement = False And UIAElement.Name = "SHOP" { + Try + ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A" + Catch + Return + Kontakt7.MoveToPluginInstrumentButton("Previous instrument") + If CheckColor() { + Kontakt7.MoveToPluginInstrumentButton(InstrumentButton) + Click + Return + } + } + AccessibilityOverlay.Speak("Instrument switching unavailable. Make sure that an instrument is loaded and that you're in classic view.") + CheckColor() { + MouseGetPos &mouseXPosition, &mouseYPosition + If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454" + Return True + Return False + } + } + } + Class ActivatePluginSnapshotButton { Static Call(SnapshotButton) { Critical @@ -261,6 +289,25 @@ Class Kontakt8 { } } + Class MoveToPluginInstrumentButton { + Static Call(InstrumentButton) { + Label := InstrumentButton + If InstrumentButton Is Object + Label := InstrumentButton.Label + UIAElement := GetUIAElement("15,1,5") + If Not UIAElement = False And UIAElement.Name = "SHOP" { + Try + ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A" + Catch + Return + If Label = "Previous instrument" + MouseMove ControlX + ControlWidth - 352, ControlY + 88 + Else + MouseMove ControlX + ControlWidth - 332, ControlY + 88 + } + } + } + Class MoveToPluginSnapshotButton { Static Call(SnapshotButton) { If SnapshotButton Is Object And InStr(SnapshotButton.Label, "Snapshot", True) diff --git a/README.md b/README.md index bb13f58..72d67d1 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,8 @@ Our changelog can be found [in our dedicated changelog file](https://github.com/ - Works both inside REAPER and in the standalone version of Komplete Kontrol. * Makes it possible to interact with Kontakt menus. - Works both inside REAPER and in the standalone version of Kontakt, Full and Player. Note that Kontakt version 7.10 or higher is required. +* Makes it possible to switch Between instruments/NKIs in Kontakt. + - Only works inside REAPER. * Makes it possible to select and cycle through snapshots in Kontakt. - Only works inside REAPER. * Provides support for the 'Browse' button in the Kontakt Content Missing dialog. @@ -105,5 +107,4 @@ HotspotHelper is a special utility to make developing these kind of scripts a li This is an incomplete list of features we're planning to look into in the future or are currently developing. Noone can guarantee that they will ever become reality, but they might at some point, and you can always open an issue to either offer help or request a new entry on this list. This list doesn't necessarily include bugfixes or additional features for entries above, except if they require special treatment and time to investigate them. -* Switching between instruments in Kontakt * Melodyne accessibility From 7b0adc49b5cc10b7f983f1e6647d595f034c0650 Mon Sep 17 00:00:00 2001 From: MatejGolian <11446675+MatejGolian@users.noreply.github.com> Date: Thu, 17 Oct 2024 17:37:03 +0200 Subject: [PATCH 2/2] Update Kontakt instrument button colors & coordinates --- Includes/Overlays/Kontakt7.ahk | 14 +++++++++----- Includes/Overlays/Kontakt8.ahk | 16 ++++++++++------ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/Includes/Overlays/Kontakt7.ahk b/Includes/Overlays/Kontakt7.ahk index 5bbf5af..73bce31 100644 --- a/Includes/Overlays/Kontakt7.ahk +++ b/Includes/Overlays/Kontakt7.ahk @@ -210,12 +210,14 @@ Class Kontakt7 { Kontakt7.MoveToPluginInstrumentButton(InstrumentButton) Click Return - } + } } AccessibilityOverlay.Speak("Instrument switching unavailable. Make sure that an instrument is loaded and that you're in rack view.") CheckColor() { MouseGetPos &mouseXPosition, &mouseYPosition - If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454" + Sleep 10 + FoundColor := PixelGetColor(MouseXPosition, MouseYPosition, "Slow") + If FoundColor = "0x545355" Or FoundColor = "0x656465" Return True Return False } @@ -248,7 +250,9 @@ Class Kontakt7 { AccessibilityOverlay.Speak("Snapshot switching unavailable. Make sure that an instrument is loaded and that you're in rack view.") CheckColor() { MouseGetPos &mouseXPosition, &mouseYPosition - If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454" + Sleep 10 + FoundColor := PixelGetColor(MouseXPosition, MouseYPosition, "Slow") + If FoundColor = "0x424142" Or FoundColor = "0x545454" Return True Return False } @@ -301,9 +305,9 @@ Class Kontakt7 { Catch Return If Label = "Previous instrument" - MouseMove ControlX + ControlWidth - 352, ControlY + 88 + MouseMove ControlX + ControlWidth - 344, ControlY + 138 Else - MouseMove ControlX + ControlWidth - 332, ControlY + 88 + MouseMove ControlX + ControlWidth - 324, ControlY + 138 } } } diff --git a/Includes/Overlays/Kontakt8.ahk b/Includes/Overlays/Kontakt8.ahk index db7360a..34e5706 100644 --- a/Includes/Overlays/Kontakt8.ahk +++ b/Includes/Overlays/Kontakt8.ahk @@ -205,9 +205,9 @@ Class Kontakt8 { ControlGetPos &ControlX, &ControlY, &ControlWidth, &ControlHeight, ReaHotkey.GetPluginControl(), "A" Catch Return - Kontakt7.MoveToPluginInstrumentButton("Previous instrument") + Kontakt8.MoveToPluginInstrumentButton("Previous instrument") If CheckColor() { - Kontakt7.MoveToPluginInstrumentButton(InstrumentButton) + Kontakt8.MoveToPluginInstrumentButton(InstrumentButton) Click Return } @@ -215,7 +215,9 @@ Class Kontakt8 { AccessibilityOverlay.Speak("Instrument switching unavailable. Make sure that an instrument is loaded and that you're in classic view.") CheckColor() { MouseGetPos &mouseXPosition, &mouseYPosition - If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454" + Sleep 10 + FoundColor := PixelGetColor(MouseXPosition, MouseYPosition, "Slow") + If FoundColor = "0x545355" Or FoundColor = "0x656465" Return True Return False } @@ -248,7 +250,9 @@ Class Kontakt8 { AccessibilityOverlay.Speak("Snapshot switching unavailable. Make sure that an instrument is loaded and that you're in classic view.") CheckColor() { MouseGetPos &mouseXPosition, &mouseYPosition - If PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x424142" Or PixelGetColor(MouseXPosition, MouseYPosition, "Slow") = "0x545454" + Sleep 10 + FoundColor := PixelGetColor(MouseXPosition, MouseYPosition, "Slow") + If FoundColor = "0x424142" Or FoundColor = "0x545454" Return True Return False } @@ -301,9 +305,9 @@ Class Kontakt8 { Catch Return If Label = "Previous instrument" - MouseMove ControlX + ControlWidth - 352, ControlY + 88 + MouseMove ControlX + ControlWidth - 344, ControlY + 138 Else - MouseMove ControlX + ControlWidth - 332, ControlY + 88 + MouseMove ControlX + ControlWidth - 324, ControlY + 138 } } }