'Python Emulate physical key press
How do you simulate a key press in Python, such that it is indistinguishable from an actual key press on a physical keyboard? I'm on a Windows 10 PC with Python 3.9.9. Notice, that none of the simple answers work such as the pynput, pyautogui, keyboard ... modules, as they rely on ctypes.windll.user32.SendInput in some way or another. And from what I've read, this function includes a flag called 'llmhf_injected' or so, which prevents it from doing anything in a window with higher integrity.
Here is the microsoft source for this
I'd like to create a simple macro that starts some programs when executed. Some of those programs require administrator permission, which my account has, but I still need to approve the UAC. All I need really is to invoke the left arrow and enter key, but due to the flag this is prevented. Also, this answer didn't work for me either.
Is it even possible to remove/prevent this flag somehow or do I need an entirely different approach?
Solution 1:[1]
In order to get by the UAC prompt you could temporarily elevate the script as it runs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 |