Mouse control

Hello I’m a newbie at Open GL but here is my question. How would I be able to keep
track of the mouse postition? What I want to do is using the left mouse button when
clicked a square appears, that I have. But using 3d space I want to be able to use
the postition of the mouse with in that space as beginning points of the square (so
that the x,y,z, coordinates would be part of the squares postition on the screen).
And as a result have different squares in different positions on the screen
Surfer GL gu