--Open Item(Var Actions depending of item source)-- --Open the Action list, right-click on the Action and Copy Sel Action ID-- --Insert the ID in the second column-- --For text ID used quotes-- --For no-action used zero-- --------------------------------- --SourceType = Action ID-- --------------------------------- --Midi Files-- MIDI = 40153 --Audio Files-- WAVE = 40638 REX = 40638 FLAC = 40638 MP3 = 40638 VORBIS = 40638 OPUS = 40638 --Video Files-- VIDEO = 50125 --Special Files-- RPP_PROJECT = 41816 EMPTY = 40850 CLICK = 40011 LTC = 40011 --if no sel item or no-action(=0)-- NoSelItem = 40113 -------------------------- --------------------------------------------------------------------- function Get_Source_Type(Item_ID) if Item_ID then Take_ID=reaper.GetActiveTake(Item_ID)--Get Active Take(from Item) if Take_ID~=nil then PCM_source = reaper.GetMediaItemTake_Source(Take_ID) S_Type = reaper.GetMediaSourceType(PCM_source,"") if S_Type == "SECTION" then PCM_source = reaper.GetMediaSourceParent(PCM_source) S_Type = reaper.GetMediaSourceType(PCM_source,"") end else S_Type = "EMPTY" end end return S_Type end function Set_ID(S_Type) --Midi Files-- if S_Type == "MIDI" then ID = MIDI --Audio Files-- elseif S_Type == "WAVE" then ID = WAVE elseif S_Type == "REX" then ID = REX elseif S_Type == "FLAC" then ID = FLAC elseif S_Type == "MP3" then ID = MP3 elseif S_Type == "VORBIS" then ID = VORBIS elseif S_Type == "OPUS" then ID = OPUS --Video Files-- elseif S_Type == "VIDEO" then ID = VIDEO --Special Files-- elseif S_Type == "RPP_PROJECT" then ID = RPP_PROJECT elseif S_Type == "EMPTY" then ID = EMPTY elseif S_Type == "CLICK" then ID = CLICK elseif S_Type == "LTC" then ID = LTC end --if non-native Action ID-- if ID and type(ID)=="string" then ID = reaper.NamedCommandLookup(ID) end --if Action no assigned-- if S_Type==nil or ID==nil or ID==0 then ID = NoSelItem --Action for others end return ID end function Run_Action() reaper.Undo_BeginBlock() reaper.Main_OnCommandEx(ID,0, 0) reaper.Undo_EndBlock("Run_Action", -1) end ---------------------------------------- Item_ID=reaper.GetSelectedMediaItem(0, 0) Get_Source_Type(Item_ID) Set_ID(S_Type) reaper.defer(Run_Action)