На пиво с вас ))При добавлении нового трека мне конкретно нужно чтобы он:
1.Раскрашивался в рандомный цвет
2.Просил ввести название трека
3.Включался мониторинг
Иногда может не срабатывать, но это редко, как смог.
		JavaScript:
	
	    local DC = {};
    local function doubleClick(interval);
       
        local Mouse_GState = reaper.JS_Mouse_GetState(1);
       
        if Mouse_GState ~= 1 then DC.dblClick = nil end;
       
        if Mouse_GState == 1 and not DC.time1 and not DC.dblClick then;
            DC.time1 = os.clock();
            DC.x1,DC.y1 = reaper.GetMousePosition();
        end;
       
       
        if Mouse_GState ~= 1 and not DC.time2 and DC.time1 then;
            DC.time2 = os.clock();
        end;
       
        if Mouse_GState == 1 and not DC.time3 and DC.time2 and DC.time1 then;
            DC.time3 = os.clock();
            DC.x2,DC.y2 = reaper.GetMousePosition();
           
            if DC.x2 < DC.x1-1    or DC.x2 > DC.x1+1 or
               DC.y2 < DC.y1-1    or DC.y2 > DC.y1+1 then
                DC.time1, DC.time2, DC.time3 = nil,nil,nil;
                DC.x2,DC.x1,DC.y2,DC.y1 = nil,nil,nil,nil;
            end;
        end;
       
       
        if DC.time1 and DC.time2 and DC.time3 then;
            if DC.time1+interval >= DC.time3 then;
                DC.time1, DC.time2, DC.time3 = nil,nil,nil;
                DC.dblClick = true;
                return true;
            else;
                DC.time1, DC.time2, DC.time3 = nil,nil,nil;
                return false;
            end;
        end;
       
       
        if DC.time1 and DC.time1+interval < os.clock()then;
            DC.time1, DC.time2, DC.time3 = nil,nil,nil;
        end
       
        return false;
    end;
   
   
    local function rand();
        local x = math.random(1,9);
        for i = 1,16 do;
            x = x..math.random(0,9);
        end;
        math.randomseed(x);
        return math.random(0,255);
    end;
   
   
   
    local lP = {};
    local function loop();
       
        local ProjState = reaper.GetProjectStateChangeCount(0)
        if ProjState ~= lP.ProjState2 then
            lP.ProjState2 = ProjState
            lastTrack = reaper.GetTrack(0,reaper.CountTracks(0)-1); 
            if lastTrack ~= lP.lastTrack2 then
                lP.lastTrack2 = lastTrack
                lP.NTR = true
            else
                lP.NTR = nil
            end
        end
       
       
        local window, segment, details = reaper.BR_GetMouseCursorContext();
        if (window == "tcp" or window == "mcp") and segment == "empty" and (not details or details == "") then;
            lP.x1,lP.y1 = reaper.GetMousePosition();
            lP.work = true;
        else
            lP.x2,lP.y2 = reaper.GetMousePosition();
            if lP.x2~=lP.x1 or lP.y2~=lP.y1 then lP.work = nil end
        end  
        
       
        if lP.work then
           
            local dblClick = doubleClick(.53)
            if dblClick then
                if lP.NTR then
               
                    -------
                    reaper.Undo_BeginBlock();
                    local lstTrack = reaper.GetTrack(0,reaper.CountTracks(0)-1);
                    local col = reaper.ColorToNative(rand(),rand(),rand());                
                    reaper.SetMediaTrackInfo_Value(lstTrack,"I_CUSTOMCOLOR",col|0x1000000);                
                                       
                    reaper.SetOnlyTrackSelected(lstTrack);
                    reaper.Main_OnCommand(40696,0);--Rename last
                    reaper.Undo_EndBlock("New Track/random color/rename",-1)
                    ------
                    lP.NTR = nil
                    lP.work = nil
                    t=(t or 0)+1
                end;
            end;
         end;
        
        reaper.defer(loop);
    end;
   
    loop();
	
			
				Последнее редактирование: