local CountSelTrack = reaper.CountSelectedTracks(0);
    if CountSelTrack == 0 then  return end;


  reaper.Undo_BeginBlock()
    ret, tracknumber, _, fxnumberOut = reaper.GetFocusedFX()


    if (ret == 0) then return end
    local track = reaper.CSurf_TrackFromID(tracknumber, false)
    _, fxname = reaper.TrackFX_GetFXName( track, fxnumberOut, '' )
    

            local Track = reaper.GetTrack(0,tracknumber );
--  track = reaper.GetSelectedTrack(0, tracknumber)
retval, i1 = reaper.GetUserInputs("EnterTrackNumber", 1, "","")    
Xtrack = reaper.CountTracks(0)    

    if (retval  == 0) or (tonumber(i1) > Xtrack)  then return end
    local Tr;
    local LastTouchedTrack = reaper.GetLastTouchedTrack();
    if LastTouchedTrack and reaper.GetMediaTrackInfo_Value(LastTouchedTrack,"I_SELECTED")==1 then;
        Tr = LastTouchedTrack else Tr = reaper.GetSelectedTrack(0,0);
    end;
    count_FX = reaper.TrackFX_GetCount(LastTouchedTrack)    


    local retval,str = reaper.GetTrackStateChunk(Tr,"",false);
    local idxSelFx = tonumber(string.match(str,"LASTSEL (%d+)"));
idxSelFx1 = idxSelFx+1 
local sel_track2 =             reaper.GetTrack(0,i1-1);
 reaper.TrackFX_CopyToTrack(track,  fxnumberOut ,sel_track2,0,0)
  reaper.Undo_EndBlock("Copy Fx to track", -1)