How to get mouse curser position in 3D view?

Operating system: window 10
Slicer version: 5.2.1


def test():

    # get crosshair 
    crosshairNode=slicer.util.getNode("Crosshair")

    pos = [0,0,0]

    crosshairNode.GetCursorPositionRAS(pos)

    print(pos)

    slicer.modules.markups.logic().AddControlPoint(pos[0], pos[1], pos[2])

This code works only in slicer view (R,Y,G), how do I make it work in 3d VIEW?