There isn’t a good way of getting blend file selection because some data don’t have a selection state. The selection used by the outliner is internal (could potentially access using ctypes).
A more simple way could be to copy the selection to an external buffer and get the references from it.
Example:
import bpy
import os
def blend_file_selection_get():
area = next((a for a in bpy.context.screen.areas
if a.type == 'OUTLINER'), None)
# No outliner, nothing to do.
if area is None:
return
# Copy selection to external buffer.
bpy.ops.outliner.id_copy({'area': area})
path = bpy.app.tempdir
buffer = "\\copybuffer.blend"
while path:
if os.path.exists(path + buffer):
path += buffer
break
path = "".join(path).rsplit("\\", 1)[:-1][0]
if path:
data = {}
# Retrieve selection from buffer.
with bpy.data.libraries.load(path) as (buffer, _):
for key in dir(buffer):
objects = getattr(buffer, key)
if objects:
data[key] = objects
# Clear buffer.
buffer = bpy.data.libraries.get("copybuffer.blend")
assert buffer is not None
bpy.data.batch_remove(ids=(buffer,))
# Get local data.
objects = []
for path, names in data.items():
dpath = getattr(bpy.data, path)
for name in names:
objects.append(dpath.get(name))
print(objects)
if __name__ == "__main__":
blend_file_selection_get()