From 3d824d048d2a70b8979bfd52e5cb3e15e94d39ef Mon Sep 17 00:00:00 2001 From: smandrap <60984250+smandrap@users.noreply.github.com> Date: Sat, 7 Oct 2023 17:56:52 +0200 Subject: [PATCH] Create smandrap_Show-hide media explorer with focus --- ...andrap_Show-hide media explorer with focus | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Various/smandrap_Show-hide media explorer with focus diff --git a/Various/smandrap_Show-hide media explorer with focus b/Various/smandrap_Show-hide media explorer with focus new file mode 100644 index 0000000..bc36d57 --- /dev/null +++ b/Various/smandrap_Show-hide media explorer with focus @@ -0,0 +1,38 @@ +-- @description Media Explorer: Show/hide media explorer with focus +-- @author smandrap +-- @version 1.0 +-- @donation https://paypal.me/smandrap +-- @about +-- Opens media explorer window and sets focus to it immediately. +-- Requires JS Api + +local reaper = reaper + +local function dependency_check() + if not reaper.JS_ReaScriptAPI_Version() then + local mb = reaper.MB('This script needs JS_API. You want to install it now?', 'Missing dependency', 1) + if mb == 2 then return false end + + if not reaper.APIExists('ReaPack_BrowsePackages') then + mb = reaper.MB('https://reapack.com/', 'Get ReaPack first.', 0) + return false + end + + reaper.ReaPack_BrowsePackages('js_ReaScript API') + end + + return true +end + + +local function main() + reaper.Main_OnCommand(50124, 0) + if reaper.GetToggleCommandState(50124) == 1 then + + local hwnd = reaper.JS_Window_Find("Media Explorer", false) + reaper.JS_Window_SetFocus(hwnd) + + end +end + +if dependency_check() then main() end