MouseDevice MouseDevice MouseDevice MouseDevice MouseDevice Class


Supports the ability to identify and track connected mouse devices.

public : sealed class MouseDevice : IMouseDevice
struct winrt::Windows::Devices::Input::MouseDevice : IMouseDevice
public sealed class MouseDevice : IMouseDevice
Public NotInheritable Class MouseDevice Implements IMouseDevice
// This class does not provide a public constructor.
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)


The Device Capabilities Sample demonstrates how to detect the presence of input devices and retrieve the capabilities and attributes of each device.


: This class is not agile, which means that you need to consider its threading model and marshaling behavior. For more info, see Threading and Marshaling (C++/CX) and Using Windows Runtime objects in a multithreaded environment (.NET).


GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView() GetForCurrentView()

Retrieves the mouse device that is associated with the current view.

public : static MouseDevice GetForCurrentView()
MouseDevice GetForCurrentView() const;
public static MouseDevice GetForCurrentView()
Public Static Function GetForCurrentView() As MouseDevice
var mouseDevice = Windows.Devices.Input.MouseDevice.getForCurrentView();


MouseMoved MouseMoved MouseMoved MouseMoved MouseMoved

Occurs when the mouse pointer is moved.

public : event TypedEventHandler MouseMoved<MouseDevice, MouseEventArgs>
// Register
event_token MouseMoved(TypedEventHandler<MouseDevice, MouseEventArgs> const& handler) const;

// Revoke with event_token
void MouseMoved(event_token const& cookie) const;

// Revoke with event_revoker
MouseMoved_revoker MouseMoved(auto_revoker_t, TypedEventHandler<MouseDevice, MouseEventArgs> const& handler) const;
public event TypedEventHandler MouseMoved<MouseDevice, MouseEventArgs>
Public Event TypedEventHandler MouseMoved( Of ( Of MouseDevice ), ( Of MouseEventArgs ))
function onMouseMoved(eventArgs){/* Your code */}

mouseDevice.addEventListener("mouseMoved", onMouseMoved);
mouseDevice.removeEventListener("mouseMoved", onMouseMoved);