Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER Q&A, Tips, Tricks and Howto

Reply
 
Thread Tools Display Modes
Old 09-01-2021, 10:01 AM   #1
IrishRover79
Human being with feelings
 
Join Date: Jun 2019
Location: Hampshire, England
Posts: 240
Default SWS resources window - auto-filtering possible based on track selection?

Hi,

Does anyone know if it's possible to have a script that:

1. automatically copies and paste the name of the first or only selected track into the filter box in the SWS Resources window
2.removes the filtering when no track is selected?

Thanks
IrishRover79 is offline   Reply With Quote
Old 09-01-2021, 10:58 AM   #2
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Using the js_ReaScriptAPI extension you could try something like this,

Code:
local title = reaper.JS_Localize('Resources', 'common')
local hwnd = reaper.JS_Window_FindTop(title, true) 
local filter = reaper.JS_Window_FindChildByID(hwnd, 0x466)
if filter then
  local track = reaper.GetSelectedTrack(0, 0) -- get first selected track
  if not track then
    reaper.JS_Window_SetTitle(filter, "")  -- erase text in filter
  else -- set filter to name of first selected track
    local _, track_name = reaper.GetSetMediaTrackInfo_String(track, "P_NAME", "", false) 
    reaper.JS_Window_SetTitle(filter, track_name)
  end
end
Edgemeal is offline   Reply With Quote
Old 09-01-2021, 02:41 PM   #3
IrishRover79
Human being with feelings
 
Join Date: Jun 2019
Location: Hampshire, England
Posts: 240
Default

that's awesome! Thank you so much. There's just one problem. The script only seems to work when the resources window is floating. I like to keep it docked on the right-hand side of my screen. Is there a tweak which would take account of that?

P.S. There is a reason why I want the window in a specific place! I'm not just being awkward. It's so that I can set up keyboard shortcuts that target specific positions on the screen, e.g. first shown slot, second shown slot etc.

Last edited by IrishRover79; 09-01-2021 at 02:42 PM. Reason: added postscript
IrishRover79 is offline   Reply With Quote
Old 09-01-2021, 02:53 PM   #4
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Try changing FindTop to Find,

Code:
local hwnd = reaper.JS_Window_Find(title, true)
Edgemeal is offline   Reply With Quote
Old 09-01-2021, 02:57 PM   #5
IrishRover79
Human being with feelings
 
Join Date: Jun 2019
Location: Hampshire, England
Posts: 240
Default

That's working! Is there some way I can 'buy you a coffee' to say thanks?
IrishRover79 is offline   Reply With Quote
Old 09-01-2021, 03:01 PM   #6
IrishRover79
Human being with feelings
 
Join Date: Jun 2019
Location: Hampshire, England
Posts: 240
Default

have just spotted your 'donate' link and have sent you something. thanks again. This is going to be so awesome!
IrishRover79 is offline   Reply With Quote
Old 09-13-2021, 10:18 AM   #7
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: ASU`ogacihC
Posts: 3,921
Default

Sorry for late reply, just wanted to say thanks for donations!
Edgemeal is offline   Reply With Quote
Old 09-14-2021, 06:04 AM   #8
IrishRover79
Human being with feelings
 
Join Date: Jun 2019
Location: Hampshire, England
Posts: 240
Default

You're welcome!
IrishRover79 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 02:31 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.