Go Back   Cockos Incorporated Forums > REAPER Forums > ReaScript, JSFX, REAPER Plug-in Extensions, Developer Forum

Thread Tools Display Modes
Old 03-26-2020, 02:48 AM   #1
Human being with feelings
Join Date: Feb 2015
Posts: 859
Default Issue with script: mpl_Send selected tracks to track under mouse cursor.lua


I would like to set up some toolbar buttons to:

- send selected tracks to VOCALS BUS
- send selected tracks to DRUMS BUS
- send selected tracks to GUITARS BUS

Note that these 'BUS' tracks already exist (so the "Create Cue Bus" actions are no good) and may already have existing receives from other tracks...

I can't find any inbuilt or SWS actions that would help set up a custom action but I did come across this script by MPL which I could possibly modify ....


Unfortunately, it doesn't work on my Reaper v6.05/x64 system - simply nothing happens.

So, has anyone got MPL's script above working OK in their set-up OR has anyone else any clever ideas on how to build a custom action to do what I described?

Many thanks,
uncleswede is offline   Reply With Quote
Old 03-26-2020, 03:13 AM   #2
Human being with feelings
solger's Avatar
Join Date: Mar 2013
Posts: 4,192

Hi Colin,

looks like there's a newer version of Send track under mouse cursor to selected tracks available on ReaPack (than the one in the thread you linked).
Just did a quick test with both versions on Windows 10 (v6.05/x64 and SWS and both seem to work here when assigned to a key shortcut.

Yeah, I guess it should be possible to modify the destination track part in the script (to get a pre-defined track instead), so you can use it in a toolbar.
- get dest track info
  window, segment, details = reaper.BR_GetMouseCursorContext()
  if segment == "track" then
    dest_track = reaper.BR_GetMouseCursorContext_Track()
    retval, track_state_chunk = reaper.GetTrackStateChunk(dest_track, "")

You might have a look at the code of Lokasenna's Select tracks by name script (available on ReaPack) for how to get a track by name.

Last edited by solger; 03-26-2020 at 03:28 AM.
solger is offline   Reply With Quote
Old 03-26-2020, 03:47 AM   #3
Human being with feelings
mpl's Avatar
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 2,650

Install latest SWS beta
SoundCloud | MPL Scripts discussion | ReaPack | Donate
mpl is offline   Reply With Quote
Old 03-26-2020, 04:41 AM   #4
Human being with feelings
Join Date: Feb 2015
Posts: 859


Thank you very much for your replies. I did take a look at Lokasenna's script and manage to modify it to my needs.

For future readers, here's the final script I came up with:

Description: Create send to named track from selected tracks 
Version: 1.40
Author: Lokasenna
Donation: https://paypal.me/Lokasenna
    Fix: Post-fader option got lost
    Modification: Removed input dialog and added variable to specify
                  a target track name (Colin Davies Mar 2019)
  Lokasenna's Website http://forum.cockos.com/member.php?u=10417
    Prompts for a track number, then creates sends to that track
    from every selected track
    . > Lokasenna_Create send from selected tracks (post-fader).lua
    . > Lokasenna_Create send from selected tracks (post-FX).lua
    . > Lokasenna_Create send from selected tracks (pre-FX).lua

-- Licensed under the GNU GPL v3

-- Change the name of the required target track below
local target_track = "ALL VOCALS"

local script_name = ({reaper.get_action_context()})[2]:match("([^/\\_]+).lua$")
local mode = string.match(script_name, "%((.+)%)")

local modes = {
  ["post-fader"] = 0,  
  ["pre-FX"] = 1,
  ["post-FX"] = 3,

local function Main()

    local num_tracks = reaper.CountSelectedTracks(0)

    if num_tracks == 0 then return end

    local dest_val 
    local dest
    if tostring(target_track) then
      for i = 0, reaper.GetNumTracks() - 1 do
      local track = reaper.GetTrack(0, i)
      local ret, name = reaper.GetTrackName(track, "")
        if ret and name == tostring(target_track) then
        dest = track

    if not dest then return end
    -- For each selected track
    local sel = {}
    for i = 0, num_tracks - 1 do
        local sel = reaper.GetSelectedTrack(0, i)
        -- Skip any tracks that are already sending to the destination
        local num_sends = reaper.GetTrackNumSends(sel, 0)
        if num_sends and num_sends > 0 then
            for i = 1, num_sends do
                --reaper.BR_GetMediaTrackSendInfo_Track( track, category, sendidx, trackType )            
                if dest == reaper.BR_GetMediaTrackSendInfo_Track(sel, 0, i-1, 1) then goto skip end       

        -- Create a default send
        --reaper.CreateTrackSend( tr, desttrInOptional )
        local idx = reaper.CreateTrackSend(sel, dest)
        if modes[mode] then
            reaper.SetTrackSendInfo_Value(sel, 0, idx, "I_SENDMODE", modes[mode])
    reaper.Undo_EndBlock("Create send from selected tracks", -1)

uncleswede is offline   Reply With Quote

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 10:43 PM.

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