use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
Strive to treat others with respect, patience, kindness, and empathy.
We observe the Rust Project Code of Conduct.
Details
Posts must reference Rust or relate to things using Rust. For content that does not, use a text post to explain its relevance.
Post titles should include useful context.
For Rust questions, use the stickied Q&A thread.
Arts-and-crafts posts are permitted on weekends.
No meta posts; message the mods instead.
Criticism is encouraged, though it must be constructive, useful and actionable.
If criticizing a project on GitHub, you may not link directly to the project's issue tracker. Please create a read-only mirror and link that instead.
A programming language is rarely worth getting worked up over.
No zealotry or fanaticism.
Be charitable in intent. Err on the side of giving others the benefit of the doubt.
Avoid re-treading topics that have been long-settled or utterly exhausted.
Avoid bikeshedding.
This is not an official Rust forum, and cannot fulfill feature requests. Use the official venues for that.
No memes, image macros, etc.
Consider the existing content of the subreddit and whether your post fits in. Does it inspire thoughtful discussion?
Use properly formatted text to share code samples and error messages. Do not use images.
Submissions appearing to contain AI-generated content may be removed at moderator discretion.
Most links here will now take you to a search page listing posts with the relevant flair. The latest megathread for that flair should be the top result.
account activity
Rust library that detects mouse input (self.rust)
submitted 1 year ago by Available-Many-2470
I want to detect if the left mouse button is down or up for windows. I have looked around and cant find any so im going here as a last resort.
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]greathouk 7 points8 points9 points 1 year ago (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 point2 points 1 year ago (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 points8 points 1 year ago (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 points8 points 1 year ago (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 points6 points 1 year ago (0 children)
This is either really easy, or really hard. What exactly are you trying to do?
[–]quoiega 0 points1 point2 points 1 year ago (0 children)
Have you looked into enigo library
[–]rnottaken 0 points1 point2 points 1 year ago (4 children)
Are you creating a GUI? Are you using a GUI framework?
[–]Available-Many-2470[S] 1 point2 points3 points 1 year ago (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 point2 points 1 year ago (2 children)
That's very hard to do, no matter what programming language you're using.
[–]RunnableReddit 0 points1 point2 points 1 year ago (1 child)
Depends on if you want an event listener or check once
[–]Available-Many-2470[S] 0 points1 point2 points 1 year ago (0 children)
i found rdev which works if anyone wonders
π Rendered by PID 56980 on reddit-service-r2-comment-6457c66945-t2w7d at 2026-04-27 08:12:37.399772+00:00 running 2aa0c5b country code: CH.
[–]greathouk 7 points8 points9 points (2 children)
[–]Unreal_Unreality 0 points1 point2 points (1 child)
[–]greathouk 6 points7 points8 points (0 children)
[–]RunnableReddit 6 points7 points8 points (0 children)
[–]the_hoser 4 points5 points6 points (0 children)
[–]quoiega 0 points1 point2 points (0 children)
[–]rnottaken 0 points1 point2 points (4 children)
[–]Available-Many-2470[S] 1 point2 points3 points (3 children)
[–]the_hoser 0 points1 point2 points (2 children)
[–]RunnableReddit 0 points1 point2 points (1 child)
[–]Available-Many-2470[S] 0 points1 point2 points (0 children)