Start / stop automatically raycast
You could modify the example operator a bit to make it work in a non-modal way. The operator can be run after MOUSEMOVE events instead, using a keymap entry.

Here's a quick example, modifying the operator (the main function is unchanged). It requires pressing the ctrl key to avoid running the operator all the time (since ray casts can be quite expensive on heavy scenes). This can be any suitable combination of events. You may also want to put this in a different keymap, e.g. for an addon.

class ViewOperatorRayCast(bpy.types.Operator):
    """Modal object selection with a ray cast"""
    bl_idname = "view3d.modal_operator_raycast"
    bl_label = "RayCast View Operator"

    @classmethod
    def poll(cls, context):
        return context.space_data.type == 'VIEW_3D'

    def invoke(self, context, event):
        main(context, event)
        return {'PASS_THROUGH'}

def register():
    bpy.utils.register_class(ViewOperatorRayCast)

    wm = bpy.context.window_manager
    kc = wm.keyconfigs['Blender User']
    km = kc.keymaps['3D View']
    kmi = km.keymap_items.new(ViewOperatorRayCast.bl_idname, 'MOUSEMOVE', 'ANY', ctrl=True)