WindowMouseX()

Syntax

x = WindowMouseX(#Window)
Description
Returns the mouse x position in the inner area of the specified window.

Parameters

#Window The window to use.

Return value

The mouse x position in the inner area of the given window. If the mouse is outside of the window area, it will return -1.

Remarks

To get the absolute x position of the mouse on the desktop, use DesktopMouseX().

Example

  Procedure TimerEvent()
    SetGadgetText(0, "Window mouse position: " + WindowMouseX(0) + ", " + WindowMouseY(0))
  EndProcedure
  
  If OpenWindow(0, 0, 0, 300, 30, "Window mouse monitor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget(0, 10, 6, 200, 20, "")
    
    AddWindowTimer(0, 0, 50) ; every 50 ms
    BindEvent(#PB_Event_Timer, @TimerEvent())
  EndIf

Supported OS

All

<- WindowID() - Window Index - WindowMouseY() ->