REAPER's MIDI editor is frustratingly secretive about its on-screen structure, with no native API functions to get its screen coordinates or CC lane heights, for example.
To try and get these CC lane heights, SWS functions such as BR_GetMouseCursorContext_MIDI, as well as MIDI scripts such as
mine, are forced to parse the state chunk of the active MIDI item, where CC lane heights are recorded in VELLANE fields.
Unfortunately, the VELLANE fields do not always accurately reflect the current state of the MIDI editor. In particular, if two or more lanes are of the same type (for example, two pitch lanes), only one of these lanes are recorded in the state chunk, and then the scripts and API functions will fail.