Get mouse x/y position while not in game engine
Yes, if you let a Modal Operator run in the background (its modal() needs to return {'PASSTHROUGH'} in order to not consume any events). An event object is passed as third parameter to modal(), which contains the mouse coordinates in window and region space, as well as information about the event itself.

You can react on mouse movements by checking the event.type:

if event.type == 'MOUSEMOVE':
    print(event.mouse_region_x, event.mouse_region_y) # remove 'region_' for window coords!


Have a look at the Operator Modal Draw template in Blender's Text Editor, it illustrates what you can do with the mouse coordinates together with a draw handler and OpenGL (bgl module).