Ruby: getting x,y position before moving the mouse?

To get the x,y position of the mouse pointer, normally you would use

    def onMouseMove(flags, x, y, view)		
    @ip.pick(view, x, y)

This code relies on the mouse being moved. But, if a tool is started with a
keypress, is it possible to immediately get the x,y position of the
mouse pointer before actually moving the mouse?

the first cursor may or may not be in the viewport, which is why you need to detect activity in the view…

I have mac code that tells me where the cursor is,

 `/usr/local/bin/cliclick p`
Current mouse position: 512,269

but then i need to check where the viewport is in the screen and check if there are other windows covering it or not…

one way I can do that is send a mouse click and check if SU records a mouse down…
if not I move the cursor toward viewport center until I get a hit…

I believe you can do something similar on Windows, but it’s so hit and miss…
I found another way to do what I needed and haven’t progressed the code past testing the theory…

why do you want the position?

Thanks for your suggestion John. I’m on win7x64 so will continue to search if there’s something similar for it.

I’m coding a ruby plugin and want to display (draw) something at the current mouse position immediately after starting the tool with a key press. It’s no biggy if I first have to slightly move the mouse but would prefer not to.