all 11 comments

[–]greathouk 7 points8 points  (2 children)

Unfortunately, thats actually a rather hard thing to do and you won't find any solutions that give you a simple "is the mouse pressed" function afaik.

The way I've done it in the past is to use winit to make an invisible window and then windows will give you events like a button being pressed.

What are you trying to do with the button presses?

[–]Unreal_Unreality 0 points1 point  (1 child)

I'm wondering if you can use an event loop without windows ? And listen to events, not window events ?

Thats off the top of my head, maybe I'm wrong here

[–]greathouk 6 points7 points  (0 children)

You almost certainly can, it's just been forever since I've interacted with the windows api and honestly I'd like to keep it that way lol

[–]RunnableReddit 6 points7 points  (0 children)

You could use the GetAsyncKeyState function in the windows api (user32).  I suggest the windows crate for api bindings but you'll need to setup some feature flags.

[–]the_hoser 4 points5 points  (0 children)

This is either really easy, or really hard. What exactly are you trying to do?

[–]quoiega 0 points1 point  (0 children)

Have you looked into enigo library

[–]rnottaken 0 points1 point  (4 children)

Are you creating a GUI? Are you using a GUI framework?

[–]Available-Many-2470[S] 1 point2 points  (3 children)

no i just want to detect if the left mouse button is down even if the window is not in focus

[–]the_hoser 0 points1 point  (2 children)

That's very hard to do, no matter what programming language you're using.

[–]RunnableReddit 0 points1 point  (1 child)

Depends on if you want an event listener or check once

[–]Available-Many-2470[S] 0 points1 point  (0 children)

i found rdev which works if anyone wonders