Task

Get the current location of the mouse cursor relative to the active window.

Please specify if the window may be externally created.




 
type MOUSE
   'mouse position, button state, wheel state
   x as integer
   y as integer
   buttons as integer
   wheel as integer
end type
 
screen 12
 
dim as MOUSE mouse
 
while inkey=""
    locate 1,1
    getmouse(mouse.x, mouse.y, mouse.wheel, mouse.buttons)
    if mouse.x < 0 then
        print "Mouse out of window.                                  "
        print "                                                      "
        print "                                                      "
    else
        print "Mouse position : ", mouse.x, mouse.y, "            "
        print "Buttons clicked: ";
        print Iif( mouse.buttons and 1, "Left      ", "          " );
        print Iif( mouse.buttons and 2, "Right     ", "          " );
        print Iif( mouse.buttons and 4, "Middle    ", "          " )
        print "Wheel scrolls: ", mouse.wheel," "
    end if
wend