-- Terminate instances
--=========================================
local function SetToggleButtonOnOff(numb);
local value,ScriptWay,sec,cmd,mod,res,val = reaper.get_action_context();
reaper.SetToggleCommandState(sec,cmd,numb or 0);
reaper.RefreshToolbar2(sec,cmd);
end;
--=========================================
--=========================================
local ProjState2;
local function ChangesInProject();
local ret;
local ProjState = reaper.GetProjectStateChangeCount(0);
if not ProjState2 or ProjState2 ~= ProjState then ret = true end;
ProjState2 = ProjState;
return ret == true;
end;
--=========================================
--=========================================
local function loop();
---
if ChangesInProject() then;
---
local CountTracks = reaper.CountTracks(0);
if CountTracks > 0 then;
----
local x,y = reaper.GetMousePosition();
local tr, info = reaper.GetTrackFromPoint(x,y);
if info == 0 and tr then;
local compact = (reaper.GetMediaTrackInfo_Value(tr,'I_FOLDERCOMPACT')==1);
if compact then;
reaper.SetMediaTrackInfo_Value(tr,'I_FOLDERCOMPACT',2);
end;
end;
----
reaper.defer(function();
for i = 1,CountTracks do;
local track = reaper.GetTrack(0,i-1);
local compact = (reaper.GetMediaTrackInfo_Value(track,'I_FOLDERCOMPACT')==1);
if compact then;
reaper.SetMediaTrackInfo_Value(track,'I_FOLDERCOMPACT',2);
end;
end;
end);
---
end;
end;
reaper.defer(loop);
end;
--=========================================
SetToggleButtonOnOff(1);
reaper.defer(loop);
reaper.atexit(SetToggleButtonOnOff);