-- TERMINATE INSTANCES !!!
-- TERMINATE INSTANCES !!!
-- 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 snapping;
local function loop();
local Mouse_State = reaper.JS_Mouse_GetState(127);
if Mouse_State&8 == 8 or Mouse_State&9 == 9 then;
if not snapping then;
snapping = reaper.GetToggleCommandStateEx(0,1157)--Toggle snapping
if snapping == 1 then;
reaper.Main_OnCommand(1157,0);
end;
end;
local window,segment,details = reaper.BR_GetMouseCursorContext();
if window == 'arrange'then;
local Mouspos = reaper.BR_GetMouseCursorContext_Position();
local EditCur = reaper.GetCursorPosition();
if Mouspos >= 0 and Mouspos ~= EditCur then;
reaper.SetEditCurPos2(0,Mouspos,false,false);
end;
end;
else;
if snapping then;
local snapping2 = reaper.GetToggleCommandStateEx(0,1157)--Toggle snapping
if snapping~=snapping2 then;
reaper.Main_OnCommand(1157,0);
snapping = nil;
end;
end;
end;
reaper.defer(loop);
end;
reaper.defer(loop);
SetToggleButtonOnOff(1);
reaper.atexit(SetToggleButtonOnOff);