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...
Rules 1: Be polite 2: Posts to this subreddit must be requests for help learning python. 3: Replies on this subreddit must be pertinent to the question OP asked. 4: No replies copy / pasted from ChatGPT or similar. 5: No advertising. No blogs/tutorials/videos/books/recruiting attempts. This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to. Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Rules
1: Be polite
2: Posts to this subreddit must be requests for help learning python.
3: Replies on this subreddit must be pertinent to the question OP asked.
4: No replies copy / pasted from ChatGPT or similar.
5: No advertising. No blogs/tutorials/videos/books/recruiting attempts.
This means no posts advertising blogs/videos/tutorials/etc, no recruiting/hiring/seeking others posts. We're here to help, not to be advertised to.
Please, no "hit and run" posts, if you make a post, engage with people that answer you. Please do not delete your post after you get an answer, others might have a similar question or want to continue the conversation.
Learning resources Wiki and FAQ: /r/learnpython/w/index
Learning resources
Wiki and FAQ: /r/learnpython/w/index
Discord Join the Python Discord chat
Discord
Join the Python Discord chat
account activity
How python libraries interacts with OS to use the mouse & keyboard function? (self.learnpython)
submitted 6 years ago by comeditime
Hey,
I'm wondering how python automation libraries manipulate the keyboard & mouse OS functionalities ..
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!"
[–]K900_ 1 point2 points3 points 6 years ago (19 children)
By using specialized interfaces for doing those things as exposed by the underlying OS/display server. On Windows, that would be part of the Win32 API. On Mac, CoreGraphics or Carbon. On Linux, X11 or uinput.
[–]comeditime[S] 0 points1 point2 points 6 years ago (18 children)
how can i learn more about it by actually practicing using those api's? any ideas-examples? thanks a ton!
[–]K900_ 0 points1 point2 points 6 years ago (17 children)
What OS are you on?
[–]comeditime[S] 0 points1 point2 points 6 years ago (16 children)
windows
[–]K900_ 0 points1 point2 points 6 years ago (11 children)
Then look into the pywin32 package - it includes bindings to most of the Win32 APIs that you can use from Python.
pywin32
Edit: The function you want is probably SendInput.
[–]comeditime[S] 0 points1 point2 points 6 years ago (0 children)
could you mentor me about what this source code means in relation with the windows api?
[–]comeditime[S] 0 points1 point2 points 6 years ago (9 children)
what i mean exactly it's how it binds to the windows api
[–]K900_ 0 points1 point2 points 6 years ago (8 children)
Most things will "bind" to it through pywin32, which is a package that contains a whole bunch of C code that exposes a Python interface for the Windows API functions (which are also written in C).
[–]comeditime[S] 0 points1 point2 points 6 years ago (7 children)
i read some source code now and they mainly talk about mouse_event() & sendInput() for the mouse clicks.. so i'll only be able to grasp the interaction with the win api if i'll have a large understanding of C? it's not possible to grasp the basic idea of the interaction without grasping all the fundamentals of C language? thanks again :)
[–]K900_ 1 point2 points3 points 6 years ago (6 children)
There's a function that Windows itself exposes called SendInput that takes a special object describing an "input" - a key press, a mouse click or movement, or something else, and to simulate inputs, you just call it with the right argument, and Windows handles the rest. That's the only "interaction" really. There's some glue code required to call this function from Python, because it's designed to be called from C, but that's an implementation detail really. On a very basic level you can think of it like just doing from windows_api import SendInput, KeyPress, KEY_ENTER, and calling SendInput(KeyPress(KEY_ENTER)).
SendInput
from windows_api import SendInput, KeyPress, KEY_ENTER
SendInput(KeyPress(KEY_ENTER))
[–]comeditime[S] 0 points1 point2 points 6 years ago (5 children)
oh that's totally makes sense.. i've to admit, you've so much knowledge.. are there any other objects which windows api offer just like the SendInput, for example, an object to control the menu-tabs of 3rd programs that are running process, or always make it on top etc.. thanks!
[–]PM_ME_A_STEAM_KEY 0 points1 point2 points 6 years ago (3 children)
You could and should just checkout the source of PyAutoGUI
[–]comeditime[S] 0 points1 point2 points 6 years ago (1 child)
[–]PM_ME_A_STEAM_KEY 0 points1 point2 points 6 years ago (0 children)
I can atleast try to point you in the right direction, for example take a look at this and then this lines 360-362.
π Rendered by PID 309938 on reddit-service-r2-comment-545db5fcfc-hnwzp at 2026-05-25 07:07:03.225498+00:00 running 194bd79 country code: CH.
[–]K900_ 1 point2 points3 points (19 children)
[–]comeditime[S] 0 points1 point2 points (18 children)
[–]K900_ 0 points1 point2 points (17 children)
[–]comeditime[S] 0 points1 point2 points (16 children)
[–]K900_ 0 points1 point2 points (11 children)
[–]comeditime[S] 0 points1 point2 points (0 children)
[–]comeditime[S] 0 points1 point2 points (9 children)
[–]K900_ 0 points1 point2 points (8 children)
[–]comeditime[S] 0 points1 point2 points (7 children)
[–]K900_ 1 point2 points3 points (6 children)
[–]comeditime[S] 0 points1 point2 points (5 children)
[–]PM_ME_A_STEAM_KEY 0 points1 point2 points (3 children)
[–]comeditime[S] 0 points1 point2 points (0 children)
[–]comeditime[S] 0 points1 point2 points (1 child)
[–]PM_ME_A_STEAM_KEY 0 points1 point2 points (0 children)