DesktopMouseX()

Syntax

Result = DesktopMouseX()
Description
Returns the absolute x position of the mouse on the desktop.

Parameters

None.

Return value

Returns the x coordinate (in pixel) of the mouse relative to the top left corner of the web page. If the mouse cursor is not inside the web page, it will returns -1.

Example

  Procedure TimerEvent()
    SetGadgetText(0, "Desktop mouse position: " + DesktopMouseX() + "," + DesktopMouseY())
  EndProcedure
  
  If OpenWindow(0, 0, 0, 300, 30, "Desktop mouse monitor", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
    TextGadget(0, 10, 6, 200, 20, "")
    
    AddWindowTimer(0, 1, 50) ; Uses a 50 ms timer for the realtime refresh
    BindEvent(#PB_Event_Timer, @TimerEvent(), 0, 1)
  EndIf

See Also

DesktopMouseY(), DesktopX(), DesktopWidth(), WindowMouseX()

Supported OS

All

<- DesktopHeight() - Desktop Index - DesktopMouseY() ->