reaper.Undo_BeginBlock() -- to create a consolidated undo point in the Undo History -- run Main window actions: reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_SAVE_CURSOR_POS_SLOT_1"),0) -- SWS/BR: Save edit cursor position, slot 01 reaper.Main_OnCommand(41174, 0) -- Item navigation: Move cursor to end of items reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_SAVE_CURSOR_POS_SLOT_2"),0) -- SWS/BR: Save edit cursor position, slot 02 reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_RESTORE_CURSOR_POS_SLOT_1"),0) -- SWS/BR: Save edit cursor position, slot 01 reaper.Main_OnCommand(41311, 0) -- Item edit: Trim right edge of item to edit cursor reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_RESTORE_CURSOR_POS_SLOT_2"),0) -- SWS/BR: Save edit cursor position, slot 02 reaper.Main_OnCommand(reaper.NamedCommandLookup("_XENAKIOS_MOVECUR10PIX_LEFTCTS"),0) -- Xenakios/SWS: Move cursor left 10 pixels, creating time selection reaper.Main_OnCommand(reaper.NamedCommandLookup("_BR_RESTORE_CURSOR_POS_SLOT_1"),0) -- SWS/BR: Save edit cursor position, slot 01 reaper.Main_OnCommand(40153, 0) -- Item: Open in built-in MIDI editor (set default behavior in preferences) hwnd = reaper.MIDIEditor_GetActive() -- get active MIDI editor -- run MIDI editor actions: reaper.MIDIEditor_OnCommand(hwnd, 40746) -- Edit: Select all notes in time selection reaper.MIDIEditor_OnCommand(hwnd, 40791) -- Edit: Trim right edge of note to edit cursor reaper.MIDIEditor_OnCommand(hwnd, 2) -- File: Close window reaper.Main_OnCommand(40635, 0) -- Time selection: Remove time selection reaper.Undo_EndBlock("Script: Expand Item and Notes to Cursor", -1 )