WindowMouseX()

Syntax

x = WindowMouseX()
Description
Returns the mouse x position in the inner area of the current window. If the mouse is outside of the window area, it will returns -1.

If you want to get the absolute x position of the mouse on the desktop, you can use the DesktopMouseX() command.
  If OpenWindow(0, 0, 0, 300, 30, #PB_Window_SystemMenu | #PB_Window_ScreenCentered, "Window mouse monitor")
    CreateGadgetList(WindowID())
      TextGadget(0, 10, 6, 200, 20, "")
    
    Repeat
      Event = WindowEvent()
      
      If Event = 0 ; No events are in the queue, so halt the process for a few milliseconds for multitasking.
        SetGadgetText(0, "Window mouse position: "+Str(WindowMouseX())+","+Str(WindowMouseY()))
        Delay(20)
      EndIf
       
    Until Event = #PB_Event_CloseWindow
  EndIf

Supported OS

All

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