Skip to main content

GetMouse

GetMouse [ /W=winName ]

The GetMouse operation returns information about the position of the input mouse, and the state of the mouse buttons.

GetMouse is useful in situations such as background tasks where the mouse position and state aren't available as they are in control procedures and window hook functions.

Flags

/W=winNameReturns the mouse position relative to the named window or subwindow. When identifying a subwindow with winName, see Subwindow Syntax.
/W=kwTopWinReturns the mouse position relative to the currently frontmost non-floating window.
/W=kwCmdHistReturns the mouse position relative to the command window.
/W=ProcedureReturns the mouse position relative to the main Procedure window.

Details

GetMouse returns the mouse position in local coordinates relative to the specified window unless /W is omitted in which case the returned coordinates are global.

Global coordinates are actually relative to the frame window. See GetWindow wsizeDC kwFrameInner.

Information is returned via the following string and numeric variables:

V_leftHorizontal mouse position, in pixels.
V_topVertical mouse position, in pixels.
V_flagMouse button state. V_flag is a bitwise value with each bit reporting the mouse button states:
bit 0:1 if the primary mouse button (usually the left) is down, 0 if it is up.
bit 1:1 if the secondary mouse button (usually the right) is down, 0 if it is up.
See Setting Bit Parameters for details about bit settings.
S_nameName of the window or subwindow which the position is relative to, or "" if not a nameable window or if /W was omitted. Most useful with /W=kwTopWin. The result can be kwCmdHist or Procedure, or the name of a target window.

See Also

GetWindow, GetKeyState, SetWindow, WMWinHookStruct, WMButtonAction, Background Tasks, Subwindow Syntax