K
K
kokapuk2022-03-07 22:28:10
C++ / C#
kokapuk, 2022-03-07 22:28:10

How can I get the mouse button state in a console application?

It does not suit me

if ((Control.MouseButtons & MouseButtons.Left) == MouseButtons.Left)
        {
            System.Diagnostics.Debug.WriteLine("Left mouse down");
        }

because I need to know this globally, even when the application is minimized.
Tried this:
Mouse.LeftButton == MouseButtonState.Pressed
but for some reason it always returns false.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vasily Bannikov, 2022-03-07
@kokapuk

because i need to know this globally even when app is minimized

Then you need to look towards any global hooks.
Here is a ready one: https://github.com/gmamaladze/globalmousekeyhook

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question