How can I press the fn+f keys with Pynput? - python

I need to be able to press the Function key along with one of the f-keys with pynput, but it doesn't seem to recognize the function key as a keypress, nor does it recognize anything as a keypress when I hit both the function and one of the f-keys.
I'm trying to make a program that will change my keyboard backlight, and to do that I need to be able to have the program press fn+f3 and fn+f4, but I can't seem to make that work. Can anyone tell me how I can do this?

Related

Simulating key presses in a game using Python

Thank you for reading this.
So e.g I start csgo, minecraft, or whatever game. When I'm in game I want to open the chat by pressing the key "y", nevertheless, I've tried using pyautogui, keyboard, win32api and win32con, they only simulate virtual key presses and I guess that's the problem since the games don't accept it as real key presses.
Is there any way I could simulate it as actual key presses?
I appreciate any answer!
Have a good day :)
I don't think Python is the right tool for this, try looking for key mappers (like KeyMapper), they simulate keypresses better afaik and you can easily bound 'y' to press whatever button opens chat in the game you want.

python: how to make programm press some buttons after if else

I have a programm which makes something when I talk in microphone. So I don't know how to make it press buttons by itself. I made a simple if else request where I say some words and it must press buttons.
If you can say how to loop it, so it won't close after a first answer to request, then you can try to help with that

How can I get keys pressed by the keyboard, even while the window isn't focused?

I'm making a key press overlay for rhythm games. How would I go about obtaining keyboard inputs outside of the Python window's focus?
I would assume you would use the keyboard module, but I can't find any documentation on it other than how to have it record and simulate key presses. Upon importing it and looking at possible functions, I see that there are some that appear to have the functionality of getting keys down/up. I have no idea how to use them though. I'm not sure if I'm even on the right track with the keyboard module but maybe one of you guys know.

Python keyboard module outputs numbers to console when arrow keys pressed

I am trying to write some code to repetitively clear the console and output a message, whenever I press a key that is added to the console as if I am in an input() state, when backspace is pressed the last letter is deleted. I also want to add a "cursor" so that when pressing arrow keys the characters selected move left and right. Everything works as expected except for the arrow keys.
So I scoured the internet for any information on this. I found 1 post, 3 years ago. It is inactive and no answer was given. The post is here. It is very similar to my question but rather then detecting a press I need to stop random outputs coming out. I am using Python 3 with Windows.
This issue happens exclusively when using the Keyboard module and when detecting arrow presses. If I do not detect the arrow presses this does not happen even when importing the module. My code is as follows:
if keyboard.is_pressed("left"):
# at this point a "4" is outputted into the console and detected when it wasn't pressed
Similarly with up arrow "8" is outputted, with down arrow a "2" is outputted, and right outputs a "6". This obviously sounds ridiculous but the post I linked above (being the only occurence I have ever read about this) clearly describes this identical problem.
They only wanted to differentiate between a 4 being pressed and a left arrow being pressed. By using keyboard.hotkey or keyboard.on_press_key, both of which I tried, there were no differences in results.
This should be extremely easy to reproduce, but I would be interested to know if anybody was unable to reproduce this and if it is linked to a specific OS or version of Python. I experienced this same problem a few years ago and quickly gave up on the mini project, now I'm re-experiencing this problem, if there is another way that I can have a function run or detect if an arrow key is currently being pressed down without these numbers being outputted, that would be a solution to this.

How do I send key presses and mouse movements to an application running in the background? (In Python)

Ok, so what I want to do is allow my program to send mouse movements and keypresses (both mouse and keyboard) to a particular task without having to be tabbed into the task so I can do other things on my computer with the mouse and keyboard while the task runs. Is it possible to do this relatively simply with existing python modules?
example of what I want to do:
task='application name'
task.leftclick
task.moveX(int)
task.moveY(int)
task.keypress(r)
All while being able to use my mouse and keyboard normally on a different application.
Thanks for the help in advance!
(Python3.6)
For anyone who happens upon this post, I found https://pypi.org/project/ahk/ I haven't looked into it fully but either you can use this or create an auto hotkey script and just call that with you python code to achieve what I wanted to do in the question.

Categories

Resources