I would suggest looking into source code of Draw Harness command vstate, which seems to be prints some information, that can be useful in your case:
Draw[22]> vstate -entities
Detected entities: b1 Depth: 109.763 Distance: 124.217 Point: 45.6609 50 64.9933 (Select3D_SensitiveTriangulation)
Detected Shape: TopoDS_TSolid b2 Depth: 118.732 Distance: 130.122 Point: 40 43.8525 61.7375 (Select3D_SensitiveTriangulation)
Detected Shape: TopoDS_TSolid b0 Depth: 124.353 Distance: 142.24 Point: 36.4524 40 59.6971 (Select3D_SensitiveTriangulation)
Detected Shape: TopoDS_TCompound
Get 3D mouse position with the depth bufferGet 3D mouse position with the depth buffer | OPEN CASCADE