def SelEnd():
    selection, startaddr, endaddr = idaapi.read_selection()

    if selection == 1:
        return endaddr
    else:
        return BADADDR
Get end address of the selected area
dataset/ETHPy150Open EiNSTeiN-/idapython/python/idc.py/SelEnd