in hexforge_modules/helper.py [0:0]
def get_selected_bytes() -> bytearray:
"""
The function generates a bytearray of selected bytes in IDA. If no bytes are selected, it returns the byte at the current cursor position.
:return: A bytearray of the selected bytes or the byte at the current cursor position if no selection is made.
"""
success, start, end = idaapi.read_range_selection(None)
if not success:
return bytearray(idaapi.get_bytes(idc.here(), 1))
size = end - start
return bytearray(idaapi.get_bytes(start, size))