--[[ If time selection is - remove time selection. If no time selection - focus main window, and hide others (e.g. MIDI Editor) Requires SWS Extension --]] sel_start, sel_end = reaper.GetSet_LoopTimeRange(false, false, 0, 0, false) close_floating_action_id = reaper.NamedCommandLookup("_S&M_WNMAIN_HIDE_OTHERS", 0) time_selection_exists = sel_start ~= sel_end if time_selection_exists then reaper.Main_OnCommand(40020, 0); -- remove selection else reaper.Main_OnCommand(close_floating_action_id, 0); -- close floating windows end